local extension = Package("sksr")
extension.extensionName = "jilvRem"

local U = require "packages/utility/utility"

Fk:loadTranslationTable{
  ["sksr"] = "极略三国-SR",
  ["sk_sr"] = "极略SR",
}

local caocao = General(extension, "sk_sr__caocao", "wei", 4)
local sk__zhaoxiangc = fk.CreateTriggerSkill{
  name = "sk__zhaoxiangc",
  anim_type = "control",
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(self) and data.card and data.card.trueName == "slash" and not target.dead
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#sk__zhaoxiangc-invoke::"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    local choices = {"sk__zhaoxiangc2"}
    if not target:isKongcheng() then
      table.insert(choices, 1, "sk__zhaoxiangc1:"..player.id)
    end
    local choice = room:askForChoice(target, choices, self.name)
    if choice ~= "sk__zhaoxiangc2" then
      local card = room:askForCardChosen(player, target, "h", self.name, "#sk__zhaoxiangc-prey::"..target.id)
      room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, false, player.id)
    else
      data.nullifiedTargets = table.map(room:getAlivePlayers(), Util.IdMapper)
    end
    if not player.dead and not player:inMyAttackRange(target) then
      room:askForDiscard(player, 1, 1, false, self.name, false)
    end
  end,
}
local sk__zhishic = fk.CreateActiveSkill{
  name = "sk__zhishic",
  anim_type = "control",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__zhishic",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local cards = room:askForDiscard(target, 1, 1, false, self.name, true,
      ".|.|.|.|.|basic", "#sk__zhishic-discard::"..player.id, true)
    if #cards > 0 then
      room:throwCard(cards, self.name, target, target)
    else
      room:damage({
        from = player,
        to = target,
        damage = 1,
        skillName = self.name,
      })
    end
    if not target.dead and target:isWounded() then
      room:recover({
        who = target,
        num = 1,
        recoverBy = player,
        skillName = self.name,
      })
    end
  end,
}
caocao:addSkill(sk__zhaoxiangc)
caocao:addSkill(sk__zhishic)
Fk:loadTranslationTable{
  ["sk_sr__caocao"] = "曹操",
  ["#sk_sr__caocao"] = "治世之道",

  ["sk__zhaoxiangc"] = "招降",
  [":sk__zhaoxiangc"] = "当一名其他角色使用【杀】指定目标后，你可以令其选择一项：1.你获得其一张手牌；2.此【杀】无效。然后若其不在你的"..
  "攻击范围内，你弃置一张牌。",
  ["sk__zhishic"] = "治世",
  [":sk__zhishic"] = "出牌阶段限一次，你可以令一名角色选择弃置一张基本牌或受到你造成的1点伤害，然后其回复1点体力。",
  ["#sk__zhaoxiangc-invoke"] = "招降：是否令 %dest 选择你获得其一张手牌，或此【杀】无效？",
  ["sk__zhaoxiangc1"] = "%src 获得你一张手牌",
  ["sk__zhaoxiangc2"] = "此【杀】无效",
  ["#sk__zhaoxiangc-prey"] = "招降：获得 %dest 一张手牌",
  ["#sk__zhishic"] = "治世：令一名角色选择弃一张基本牌或受到1点伤害，然后其回复1点体力",
  ["#sk__zhishic-discard"] = "治世：弃一张基本牌或点“取消”受到1点伤害，然后你回复1点体力",

  ["$sk__zhaoxiangc"] = "汝可愿降于我，为我所用？",
  ["$sk__zhishic1"] = "用人唯才，治世以法。",
  ["$sk__zhishic2"] = "须得百姓亲附，甲兵强盛。",
  ["~sk_sr__caocao"] = "孤之霸业竟有终结之时……",
}

local simayi = General(extension, "sk_sr__simayi", "wei", 3)
local sk__guicai = fk.CreateTriggerSkill{
  name = "sk__guicai",
  anim_type = "control",
  events = {fk.AskForRetrial},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self)
  end,
  on_cost = function(self, event, target, player, data)
    local extra_data = {
      num = 1,
      min_num = 0,
      include_equip = false,
      skillName = self.name,
      pattern = ".",
    }
    local success, dat = player.room:askForUseActiveSkill(player, "choose_cards_skill",
      "#sk__guicai-invoke::"..target.id, true, extra_data)
    if success then
      self.cost_data = dat.cards or {}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if #self.cost_data > 0 then
      room:retrial(Fk:getCardById(self.cost_data[1]), player, data, self.name)
    else
      local move1 = {
        ids = room:getNCards(1),
        toArea = Card.Processing,
        moveReason = fk.ReasonJustMove,
        skillName = self.name,
        proposer = player.id,
      }
      local move2 = {
        ids = {data.card:getEffectiveId()},
        toArea = Card.DiscardPile,
        moveReason = fk.ReasonJustMove,
        skillName = self.name,
      }
      room:moveCards(move1, move2)
      data.card = Fk:getCardById(move1.ids[1])
      room:sendLog{
        type = "#ChangedJudge",
        from = player.id,
        to = {player.id},
        card = {move1.ids[1]},
        arg = self.name
      }
    end
  end,
}
local sk__langgu = fk.CreateTriggerSkill{
  name = "sk__langgu",
  anim_type = "masochism",
  events = {fk.Damage},
  can_trigger = function(self, event, target, player, data)
    return target and player:hasSkill(self) and (target == player or data.to == player) and data.from ~= data.to
  end,
  on_cost = function(self, event, target, player, data)
    local to = data.to
    if target ~= player then
      to = data.from
    end
    if player.room:askForSkillInvoke(player, self.name, nil, "#sk__langgu-invoke::"..to.id) then
      self.cost_data = to
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = self.cost_data
    room:doIndicate(player.id, {to.id})
    local judge = {
      who = target,
      reason = self.name,
      pattern = ".|.|spade,club",
    }
    room:judge(judge)
    if to.dead or player.dead or to:isNude() then return end
    if judge.card.color == Card.Black then
      local card = room:askForCardChosen(player, to, "he", self.name, "#sk__langgu-prey::"..to.id)
      room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, false, player.id)
    end
  end,
}
local sk__zhuizun = fk.CreateTriggerSkill{
  name = "sk__zhuizun",
  anim_type = "defensive",
  frequency = Skill.Limited,
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.dying and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:recover({
      who = player,
      num = 1 - player.hp,
      recoverBy = player,
      skillName = self.name,
    })
    room:doIndicate(player.id, table.map(room:getOtherPlayers(player), Util.IdMapper))
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if player.dead then return end
      if not p.dead and not p:isKongcheng() then
        local card = room:askForCard(p, 1, 1, false, self.name, false, ".", "#sk__zhuizun-give:"..player.id)
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonGive, self.name, nil, false, p.id)
      end
    end
    if not player.dead then
      player:gainAnExtraTurn(true, self.name)
    end
  end,
}
simayi:addSkill(sk__guicai)
simayi:addSkill(sk__langgu)
simayi:addSkill(sk__zhuizun)
Fk:loadTranslationTable{
  ["sk_sr__simayi"] = "司马懿",
  ["#sk_sr__simayi"] = "深冢之虎",

  ["sk__guicai"] = "鬼才",
  [":sk__guicai"] = "当一名角色的判定结果确定前，你可以打出一张手牌或用牌堆顶牌代替之。",
  ["sk__langgu"] = "狼顾",
  [":sk__langgu"] = "当你对其他角色造成伤害后，或当其他角色对你造成伤害后，你可以判定，若结果为黑色，你获得其一张牌。",
  ["sk__zhuizun"] = "追尊",
  [":sk__zhuizun"] = "限定技，当你进入濒死状态时，你可以回复体力至1点，然后令所有其他角色各交给你一张手牌，你于此回合结束后进行一个额外回合。",
  ["#sk__guicai-invoke"] = "鬼才：你可以打出一张手牌或用牌堆顶牌修改 %dest 的判定<br>"..
  "（选择一张手牌，或直接点“确定”用牌堆顶牌修改判定）",
  ["#sk__langgu-invoke"] = "狼顾：你可以判定，若为黑色，你获得 %dest 一张牌",
  ["#sk__langgu-prey"] = "狼顾：获得 %dest 的一张牌",
  ["#sk__zhuizun-give"] = "追尊：请交给 %src 一张手牌",

  ["$sk__guicai"] = "哼，我已等待多时。",
  ["$sk__langgu"] = "不自量力！",
  ["$sk__zhuizun"] = "我才是胜者，哈哈哈哈哈哈哈！",
  ["~sk_sr__simayi"] = "难道全被识破了吗？",
}

local xiahoudun = General(extension, "sk_sr__xiahoudun", "wei", 4)
local sk__zhonghou = fk.CreateViewAsSkill{
  name = "sk__zhonghou",
  pattern = ".|.|.|.|.|basic",
  prompt = "#sk__zhonghou",
  interaction = function(self,player)
    local all_names = U.getAllCardNames("b")
    local names = U.getViewAsCardNames(player, self.name, all_names)
    if #names == 0 then return false end
    return UI.ComboBox { choices = names, all_choices = all_names }
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, cards,player)
    if not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, use)
    player.room:loseHp(player, 1, self.name)
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
  end,
  enabled_at_response = function(self, player, response)
    return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
  end,
}
local sk__zhonghou_trigger = fk.CreateTriggerSkill{
  name = "#sk__zhonghou_trigger",

  refresh_events = {fk.GameStart, fk.EventAcquireSkill, fk.EventLoseSkill, fk.Deathed},
  can_refresh = function(self, event, target, player, data)
    if event == fk.GameStart then
      return player:hasSkill("sk__zhonghou", true)
    elseif event == fk.EventAcquireSkill or event == fk.EventLoseSkill then
      return target == player and data == sk__zhonghou
    else
      return target == player and player:hasSkill("sk__zhonghou", true, true)
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart or event == fk.EventAcquireSkill then
      for _, p in ipairs(room:getOtherPlayers(player)) do
        room:handleAddLoseSkills(p, "sk__zhonghou&", nil, false, true)
      end
    elseif (event == fk.EventLoseSkill or event == fk.Deathed) and
      not table.find(room:getOtherPlayers(player), function (p)
        return p:hasSkill("sk__zhonghou", true)
      end) then
      for _, p in ipairs(room:getOtherPlayers(player, true, true)) do
        room:handleAddLoseSkills(p, "-sk__zhonghou&", nil, false, true)
      end
    end
  end,
}
local sk__zhonghou_viewas = fk.CreateViewAsSkill{
  name = "sk__zhonghou&",
  pattern = ".|.|.|.|.|basic",
  prompt = "#sk__zhonghou&",
  interaction = function(self,player)
    local all_names = U.getAllCardNames("b")
    local names = U.getViewAsCardNames(player, self.name, all_names)
    if #names == 0 then return false end
    return U.CardNameBox { choices = names, all_choices = all_names }
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, cards,player)
    if not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    local yes = false
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if p:hasSkill("sk__zhonghou") and p:inMyAttackRange(player) then
        if room:askForSkillInvoke(p, "sk__zhonghou", nil, "#sk__zhonghou-ask::"..player.id..":"..use.card.name) then
          room:loseHp(p, 1, "sk__zhonghou")
          yes = true
          break
        end
      end
    end
    if not yes then
      return ""
    end
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and
      table.find(Fk:currentRoom().alive_players, function (p)
        return p:hasSkill("sk__zhonghou") and p ~= player and p:inMyAttackRange(player)
      end)
  end,
  enabled_at_response = function(self, player, response)
    return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and
      table.find(Fk:currentRoom().alive_players, function (p)
        return p:hasSkill("sk__zhonghou") and p ~= player and p:inMyAttackRange(player)
      end)
  end,
}
local sk__ganglie = fk.CreateTriggerSkill{
  name = "sk__ganglie",
  anim_type = "offensive",
  events = {fk.EventPhaseStart, fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) then
      if event == fk.EventPhaseStart then
        return player.phase == Player.Play
      else
        return #player.room.logic:getActualDamageEvents(1, function(e)
          local damage = e.data[1]
          return damage.from and damage.from == player
        end, Player.HistoryTurn) > 0
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
      return player.room:askForSkillInvoke(player, self.name)
    else
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      room:loseHp(target, 1, self.name)
    else
      local n = 0
      room.logic:getActualDamageEvents(1, function(e)
        local damage = e.data[1]
        if damage.from and damage.from == player then
          n = n + damage.damage
        end
        return false
      end, Player.HistoryTurn)
      player:drawCards(n, self.name)
    end
  end,
}
local sk__ganglie_trigger = fk.CreateTriggerSkill{
  name = "#sk__ganglie_trigger",
  mute = true,
  events = {fk.DamageCaused},
  can_trigger = function(self, event, target, player, data)
    return target and target == player and player:usedSkillTimes("sk__ganglie", Player.HistoryTurn) > 0 and not data.chain
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:broadcastSkillInvoke("sk__ganglie")
    player.room:notifySkillInvoked(player, "sk__ganglie", "offensive")
    data.damage = data.damage + 1
  end,
}
sk__zhonghou:addRelatedSkill(sk__zhonghou_trigger)
Fk:addSkill(sk__zhonghou_viewas)
sk__zhonghou:addRelatedSkill(sk__ganglie_trigger)
xiahoudun:addSkill(sk__zhonghou)
xiahoudun:addSkill(sk__ganglie)
Fk:loadTranslationTable{
  ["sk_sr__xiahoudun"] = "夏侯惇",
  ["#sk_sr__xiahoudun"] = "啖睛苍狼",

  ["sk__zhonghou"] = "忠侯",
  [":sk__zhonghou"] = "每名角色每回合限一次，当你或你攻击范围内的角色需使用或打出基本牌时，其可以声明之，然后你可以失去1点体力，视为其"..
  "使用或打出之。",
  ["sk__ganglie"] = "刚烈",
  [":sk__ganglie"] = "出牌阶段开始时，你可以失去1点体力，令你本回合造成伤害+1。回合结束时，你摸等同于你本回合造成伤害值的牌。",
  ["#sk__zhonghou"] = "忠侯：你可以失去1点体力，视为使用或打出基本牌",
  ["sk__zhonghou&"] = "忠侯",
  [":sk__zhonghou&"] = "每回合限一次，当你需使用或打出基本牌时，若你在夏侯惇的攻击范围内，你可以声明之，然后夏侯惇可以失去1点体力，视为你"..
  "使用或打出之。",
  ["#sk__zhonghou&"] = "忠侯：你可以声明使用或打出基本牌，夏侯惇可以失去1点体力，视为你使用或打出之",
  ["#sk__zhonghou-ask"] = "忠侯：是否失去1点体力，允许 %dest 视为使用或打出【%arg】？",

  ["$sk__zhonghou"] = "放手一搏吧！",
  ["$sk__ganglie"] = "你能逃得掉吗！",
  ["~sk_sr__xiahoudun"] = "这仇，早晚要报！",
}

local zhangliao = General(extension, "sk_sr__zhangliao", "wei", 4)
local sk__wuwei = fk.CreateTriggerSkill{
  name = "sk__wuwei",
  anim_type = "offensive",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Draw
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:getNCards(3)
    room:moveCardTo(cards, Card.Processing, nil, fk.ReasonJustMove, self.name, nil, true, player.id)
    room:delay(800)
    local obtain, basic_cards = {}, {}
    for _, id in ipairs(cards) do
      if Fk:getCardById(id).type == Card.TypeBasic then
        table.insert(basic_cards, id)
      else
        table.insert(obtain, id)
      end
    end
    if #basic_cards > 0 then
      room:moveCardTo(basic_cards, Card.DiscardPile, nil, fk.ReasonJustMove, self.name, nil, true, player.id)
    end
    if #obtain > 0 then
      room:moveCardTo(obtain, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
    end
    room:delay(800)
    if not player.dead and #basic_cards > 0 then
      for i = 1, #basic_cards, 1 do
        if player.dead or not player:canUse(Fk:cloneCard("slash")) then return end
        local use = U.askForUseVirtualCard(player.room, player, "slash", nil, self.name,
          "#sk__wuwei-invoke", true, false, false, true, nil, true)
        if use then
          room:useCard(use)
        else
          break
        end
      end
    end
    return true
  end,
}
local sk__yansha = fk.CreateTriggerSkill{
  name = "sk__yansha",
  anim_type = "control",
  expand_pile = "sk_sr__zhangliao_yan",
  events = {fk.EventPhaseStart, fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      if event == fk.EventPhaseStart then
        return target == player and player.phase == Player.Finish and not player:isKongcheng()
      else
        return target ~= player and data.card and data.card.trueName == "slash" and not target.dead and not target:isKongcheng() and
          #player:getPile("sk_sr__zhangliao_yan") > 0
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local cards = {}
    if event == fk.EventPhaseStart then
      cards = room:askForCard(player, 1, 1, false, self.name, true, ".", "#sk__yansha-put")
    else
      cards = room:askForCard(player, 1, 1, false, self.name, true, ".|.|.|sk_sr__zhangliao_yan",
        "#sk__yansha-invoke::"..target.id, "sk_sr__zhangliao_yan")
    end
    if #cards > 0 then
      self.cost_data = cards
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      player:addToPile("sk_sr__zhangliao_yan", self.cost_data, false, self.name, player.id)
    else
      room:doIndicate(player.id, {target.id})
      room:moveCardTo(self.cost_data, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, self.name, nil, true, player.id)
      if not player.dead and not target.dead and not target:isKongcheng() then
        local cards = room:askForCardsChosen(player, target, 1, 2, "h", self.name, "#sk__yansha-prey::"..target.id)
        room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, false, player.id)
      end
    end
  end,
}
zhangliao:addSkill(sk__wuwei)
zhangliao:addSkill(sk__yansha)
Fk:loadTranslationTable{
  ["sk_sr__zhangliao"] = "张辽",
  ["#sk_sr__zhangliao"] = "古之召虎",

  ["sk__wuwei"] = "无畏",
  [":sk__wuwei"] = "摸牌阶段，你可以放弃摸牌，改为亮出牌堆顶的三张牌，将其中的基本牌置入弃牌堆，你获得其余的牌，然后你可以视为使用X张【杀】"..
  "（X为以此法置入弃牌堆的牌数）。",
  ["sk__yansha"] = "掩杀",
  [":sk__yansha"] = "结束阶段，你可以将一张手牌置于武将牌上，称为“掩”。当其他角色使用【杀】指定目标后，你可以将一张“掩”置入弃牌堆，获得其"..
  "至多两张手牌。",
  ["#sk__wuwei-invoke"] = "无畏：你可以视为使用【杀】",
  ["sk_sr__zhangliao_yan"] = "掩",
  ["#sk__yansha-put"] = "掩杀：你可以将一张手牌置为“掩”",
  ["#sk__yansha-invoke"] = "掩杀：你可以移去一张“掩”，获得 %dest 两张手牌",
  ["#sk__yansha-prey"] = "掩杀：获得 %dest 两张手牌",

  ["$sk__wuwei"] = "记住我军的强大吧！",
  ["$sk__yansha1"] = "兵贵神速，随我来！",
  ["$sk__yansha2"] = "行包围之势，尽数诛之！",
  ["~sk_sr__zhangliao"] = "我张文远竟受此污名！",
}

local xuchu = General(extension, "sk_sr__xuchu", "wei", 4)
local sk__aozhan = fk.CreateActiveSkill{
  name = "sk__aozhan",
  anim_type = "drawcard",
  card_num = 0,
  target_num = 0,
  prompt = "#sk__aozhan",
  derived_piles = "sk__aozhan",
  interaction = function()
    return UI.ComboBox {choices = {"prey", "recast"}}
  end,
  card_filter = Util.FalseFunc,
  can_use = function(self, player)
    return #player:getPile("sk__aozhan") > 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    if self.interaction.data == "prey" then
      room:moveCardTo(player:getPile("sk__aozhan"), Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, false, player.id)
    else
      room:recastCard(player:getPile("sk__aozhan"), player, self.name)
    end
  end,
}
local sk__aozhan_trigger = fk.CreateTriggerSkill{
  name = "#sk__aozhan_trigger",
  mute = true,
  events = {fk.Damage, fk.Damaged},
  main_skill = sk__aozhan,
  can_trigger = function(self, event, target, player, data)
    return target and target == player and player:hasSkill(sk__aozhan) and data.card and
      (data.card.trueName == "slash" or data.card.trueName == "duel")
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("sk__aozhan")
    room:notifySkillInvoked(player, "sk__aozhan", "special")
    player:addToPile("sk__aozhan", room:getNCards(data.damage), false, "sk__aozhan", player.id)
  end
}
local sk__huxiao = fk.CreateTriggerSkill{
  name = "sk__huxiao",
  anim_type = "offensive",
  events = {fk.DamageCaused},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and data.card.trueName == "slash" and
      player.phase == Player.Play
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#sk__huxiao-invoke::"..data.to.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:turnOver()
    if not player.dead then
      player:drawCards(1, self.name)
    end
    data.damage = data.damage + 1
    local current = room.logic:getCurrentEvent()
    local use_event = current:findParent(GameEvent.UseCard)
    if not use_event then return end
    local turn_event = use_event:findParent(GameEvent.Turn)
    if not turn_event then return end
    use_event:addExitFunc(function()
      turn_event:shutdown()
    end)
  end,
}
sk__aozhan:addRelatedSkill(sk__aozhan_trigger)
xuchu:addSkill(sk__aozhan)
xuchu:addSkill(sk__huxiao)
Fk:loadTranslationTable{
  ["sk_sr__xuchu"] = "许褚",
  ["#sk_sr__xuchu"] = "甘效死命",

  ["sk__aozhan"] = "鏖战",
  [":sk__aozhan"] = "当你使用【杀】或【决斗】造成1点伤害后，或受到【杀】或【决斗】造成的1点伤害后，你将牌堆顶牌置于武将牌上。"..
  "出牌阶段，你可以获得或重铸所有“鏖战”牌。",
  ["sk__huxiao"] = "虎啸",
  [":sk__huxiao"] = "你的出牌阶段内，当你使用【杀】造成伤害时，你可以翻面并摸一张牌，令此伤害+1，若如此做，此【杀】结算后，结束此回合。",
  ["#sk__aozhan"] = "鏖战：你可以获得或重铸所有“鏖战”牌",
  ["#sk__aozhan_trigger"] = "鏖战",
  ["#sk__huxiao-invoke"] = "虎啸：是否翻面并摸一张牌，令你对 %dest 造成的伤害+1并结束此回合？",

  ["$sk__aozhan1"] = "哈哈哈哈哈！来送死的吧！",
  ["$sk__aozhan2"] = "这一招如何！",
  ["$sk__huxiao"] = "纳命来！",
  ["~sk_sr__xuchu"] = "我还能……接着打……",
}

local guojia = General(extension, "sk_sr__guojia", "wei", 3)
local sk__tianshang = fk.CreateTriggerSkill{
  name = "sk__tianshang",
  anim_type = "support",
  events = {fk.Death},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self, false, true)
  end,
  on_cost = function(self, event, target, player, data)
    local to = player.room:askForChoosePlayers(player, table.map(player.room.alive_players, Util.IdMapper), 1, 1,
      "#sk__tianshang-choose", self.name, true)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    local skills = {}
    for _, s in ipairs(player.player_skills) do
      if s:isPlayerSkill(player) and s.visible and s ~= self and not to:hasSkill(s, true) then
        table.insert(skills, s.name)
      end
    end
    if #skills > 0 then
      local result = room:askForCustomDialog(player, self.name,
        "packages/utility/qml/ChooseSkillBox.qml", {
        skills, 1, 1, "#sk__tianshang-choice::"..to.id
      })
      local skill = ""
      if result == "" then
        skill = table.random(skills)
      end
      local choice = json.decode(result)
      if #choice > 0 then
        skill = choice[1]
      else
        skill = table.random(skills)
      end
      room:handleAddLoseSkills(to, skill, nil, true, false)
    end
    if not to.dead then
      room:changeMaxHp(to, 1)
    end
    if to:isWounded() and not to.dead then
      room:recover{
        who = to,
        num = 1,
        recoverBy = player,
        skillName = self.name,
      }
    end
  end,
}
local sk__huiqu = fk.CreateTriggerSkill{
  name = "sk__huiqu",
  anim_type = "control",
  events = {fk.TurnStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForDiscard(player, 1, 1, false, self.name, true, ".", "#sk__huiqu-invoke", true)
    if #card > 0 then
      self.cost_data = card
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard(self.cost_data, self.name, player, player)
    if player.dead then return end
    local judge = {
      who = target,
      reason = self.name,
      pattern = ".",
    }
    room:judge(judge)
    if player.dead then return end
    if judge.card.color == Card.Red then
      local targets = room:askForChooseToMoveCardInBoard(player, "#sk__huiqu-move", self.name, false, nil)
      if #targets ~= 0 then
        targets = table.map(targets, Util.Id2PlayerMapper)
        room:askForMoveCardInBoard(player, targets[1], targets[2], self.name)
      end
    elseif judge.card.color == Card.Black then
      local to = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, 1,
        "#sk__huiqu-choose", self.name, false)
      to = room:getPlayerById(to[1])
      room:damage{
        from = player,
        to = to,
        damage = 1,
        skillName = self.name,
      }
      if not to.dead then
        to:drawCards(1, self.name)
      end
    end
  end,
}
guojia:addSkill(sk__tianshang)
guojia:addSkill(sk__huiqu)
guojia:addSkill("ex__yiji")
Fk:loadTranslationTable{
  ["sk_sr__guojia"] = "郭嘉",
  ["#sk_sr__guojia"] = "天妒英才",

  ["sk__tianshang"] = "天殇",
  [":sk__tianshang"] = "当你死亡时，你可以令一名其他角色获得你除〖天殇〗以外的一个技能，然后其加1点体力上限，回复1点体力。",
  ["sk__huiqu"] = "慧觑",
  [":sk__huiqu"] = "准备阶段，你可以弃置一张手牌并判定，若结果为：红色，你移动场上的一张牌；黑色，你对一名角色造成1点伤害，然后其摸一张牌。",
  ["#sk__tianshang-choose"] = "天殇：令一名角色获得你的一个技能，加1点体力上限并回复1点体力",
  ["#sk__tianshang-choice"] = "天殇：选择令 %dest 获得的技能",
  ["#sk__huiqu-invoke"] = "慧觑：你可以弃一张手牌进行判定，根据颜色执行效果",
  ["#sk__huiqu-move"] = "慧觑：请移动场上的一张牌",
  ["#sk__huiqu-choose"] = "慧觑：对一名角色造成1点伤害，然后其摸一张牌",

  ["$sk__huiqu"] = "且看你如何化解。",
  ["~sk_sr__guojia"] = "岂能尽如人意……",
}

local zhenji = General(extension, "sk_sr__zhenji", "wei", 3, 3, General.Female)
local sk__liuyun = fk.CreateActiveSkill{
  name = "sk__liuyun",
  anim_type = "support",
  card_num = 1,
  target_num = 1,
  prompt = "#sk__liuyun",
  can_use = function(self, player)
    return not player.chained and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, to_select, selected,player)
    return #selected == 0 and Fk:getCardById(to_select).color == Card.Black and
      not player:prohibitDiscard(to_select)
  end,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    room:throwCard(effect.cards, self.name, player, player)
    if not player.dead and not player.chained then
      player:setChainState(true)
    end
    if target.dead then return end
    local choices = {"draw2"}
    if target:isWounded() then
      table.insert(choices, "recover")
    end
    local choice = room:askForChoice(target, choices, self.name)
    if choice == "draw2" then
      target:drawCards(2, self.name)
    else
      room:recover({
        who = target,
        num = 1,
        recoverBy = player,
        skillName = self.name,
      })
    end
  end,
}
local sk__lingbo = fk.CreateTriggerSkill{
  name = "sk__lingbo",
  anim_type = "control",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target.phase == Player.Start and player.chained
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player.chained then
      player:setChainState(false)
    end
    if player.dead then return end
    local targets = table.filter(player.room.alive_players, function(p)
      return #p:getCardIds("ej") > 0
    end)
    if #targets == 0 then return end
    local to = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#sk__lingbo-choose", self.name, false)
    to = room:getPlayerById(to[1])
    local card = room:askForCardChosen(player, to, "ej", self.name, "#sk__lingbo-card::"..to.id)
    room:moveCards({
      ids = {card},
      from = to.id,
      toArea = Card.DrawPile,
      moveReason = fk.ReasonPut,
      skillName = self.name,
      proposer = player.id,
      drawPilePosition = 1,
    })
  end,
}
local sk__qingcheng = fk.CreateViewAsSkill{
  name = "sk__qingcheng",
  pattern = "slash,jink",
  anim_type = "defensive",
  prompt = function()
    if Self.chained then
      return "#sk__qingcheng-jink"
    else
      return "#sk__qingcheng-slash"
    end
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, cards,player)
    local card
    if player:hasSkill(self) then
      if player.chained then
        card = Fk:cloneCard("jink")
      else
        card = Fk:cloneCard("slash")
      end
    end
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, use)
    if player.chained then
      player:setChainState(false)
    else
      player:setChainState(true)
    end
  end,
  enabled_at_play = function (self, player)
    return not player.chained
  end,
  enabled_at_response = function (self, player, response)
    if player.chained then
      return Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(Fk:cloneCard("jink"))
    else
      return Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(Fk:cloneCard("slash"))
    end
  end,
}
zhenji:addSkill(sk__liuyun)
zhenji:addSkill(sk__lingbo)
zhenji:addSkill(sk__qingcheng)
Fk:loadTranslationTable{
  ["sk_sr__zhenji"] = "甄姬",
  ["#sk_sr__zhenji"] = "轻云蔽月",

  ["sk__liuyun"] = "流云",
  [":sk__liuyun"] = "出牌阶段限一次，你可以横置并弃置一张黑色牌，令一名角色选择回复1点体力或摸两张牌。",
  ["sk__lingbo"] = "凌波",
  [":sk__lingbo"] = "一名角色准备阶段，你可以重置，然后将场上的一张牌置于牌堆顶。",
  ["sk__qingcheng"] = "倾城",
  [":sk__qingcheng"] = "你可以横置，视为使用或打出一张【杀】；你可以重置，视为使用或打出一张【闪】。",
  ["#sk__liuyun"] = "流云：弃一张黑色牌并横置，令一名角色选择回复1点体力或摸两张牌",
  ["#sk__lingbo-choose"] = "凌波：选择一名角色，将其场上一张牌置于牌堆顶",
  ["#sk__lingbo-card"] = "凌波：将 %dest 场上一张牌置于牌堆顶",
  ["#sk__qingcheng-slash"] = "倾城：你可以横置，视为使用或打出一张【杀】",
  ["#sk__qingcheng-jink"] = "倾城：你可以重置，视为使用或打出一张【闪】",

  ["$sk__liuyun"] = "髣髴兮若轻云之蔽月。",
  ["$sk__lingbo"] = "飘飖兮若流风之回雪。",
  ["$sk__qingcheng"] = "含辞未吐，气若幽兰。",
  ["~sk_sr__zhenji"] = "悼良会之永绝兮，哀一逝而异乡。",
}

local liubei = General(extension, "sk_sr__liubei", "shu", 4)
local sk__rende = fk.CreateTriggerSkill{
  name = "sk__rende",
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(self) and target.phase == Player.Finish and not target.dead and
      not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local cards = player.room:askForCard(player, 1, 999, false, self.name, true, nil, "#sk__rende-invoke::"..target.id)
    if #cards > 0 then
      self.cost_data = cards
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:moveCardTo(self.cost_data, Card.PlayerHand, target, fk.ReasonGive, self.name, nil, false, player.id)
    if not target.dead then
      target:gainAnExtraPhase(Player.Play, true)
    end
  end,
}
local sk__chouxi = fk.CreateActiveSkill{
  name = "sk__chouxi",
  anim_type = "offensive",
  card_num = 1,
  target_num = 1,
  prompt = "#sk__chouxi",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, to_select, selected,player)
    return #selected == 0 and not player:prohibitDiscard(to_select)
  end,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0 and to_select ~= player.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    room:throwCard(effect.cards, self.name, player, player)
    if player.dead then return end
    local cards = room:getNCards(3)
    room:moveCardTo(cards, Card.Processing, nil, fk.ReasonJustMove, self.name, nil, true, player.id)
    local types = {"basic", "trick", "equip"}
    local choices = {}
    for _, id in ipairs(cards) do
      local type = Fk:getCardById(id):getTypeString()
      table.removeOne(types, type)
      table.insertIfNeed(choices, type)
    end
    if #room:askForDiscard(target, 1, 1, false, self.name, true, ".|.|.|.|.|"..table.concat(types, ","),
      "#sk__chouxi-discard:"..player.id) > 0 then
      if not player.dead then
        room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
      end
    else
      room:damage{
        from = player,
        to = target,
        damage = 1,
        skillName = self.name,
      }
      if target.dead then
        room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
      else
        local _, choice = U.askforChooseCardsAndChoice(target, cards, choices, self.name,
          "#sk__chouxi-get:"..player.id, nil, 0, 0, cards)
        local obtain, discard = {}, {}
        for _, id in ipairs(cards) do
          if Fk:getCardById(id):getTypeString() == choice then
            table.insert(obtain, id)
          else
            table.insert(discard, id)
          end
        end
        room:moveCardTo(obtain, Card.PlayerHand, target, fk.ReasonJustMove, self.name, nil, true, target.id)
        if #discard > 0 then
          if player.dead then
            room:moveCardTo(discard, Card.DiscardPile, nil, fk.ReasonJustMove, self.name, nil, true, nil)
          else
            room:moveCardTo(discard, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
          end
        end
      end
    end
  end,
}
liubei:addSkill(sk__rende)
liubei:addSkill(sk__chouxi)
Fk:loadTranslationTable{
  ["sk_sr__liubei"] = "刘备",
  ["#sk_sr__liubei"] = "汉昭烈帝",

  ["sk__rende"] = "仁德",
  [":sk__rende"] = "其他角色结束阶段，你可以交给其任意张手牌，然后其于此回合结束后进行一个额外出牌阶段。",
  ["sk__chouxi"] = "仇袭",
  [":sk__chouxi"] = "出牌阶段限一次，你可以弃置一张牌并亮出牌堆顶三张牌，令一名其他角色选择一项：1.弃置一张与展示的牌类别均不同的牌，"..
  "你获得展示的牌；2.你对其造成1点伤害，其获得其中一种类别的牌，你获得其余的牌。",
  ["#sk__rende-invoke"] = "仁德：你可以交给 %dest 任意张手牌，令其获得一个额外出牌阶段",
  ["#sk__chouxi"] = "仇袭：弃置一张牌，亮出牌堆顶三张牌，令一名角色执行效果",
  ["#sk__chouxi-discard"] = "仇袭：弃置一张类别不同的牌令 %src 获得这些牌，或点“取消”受到1点伤害，双方获得牌",
  ["#sk__chouxi-get"] = "仇袭：获得其中一种类别的牌，%src获得其余的牌",

  ["$sk__rende"] = "以德服人。",
  ["$sk__chouxi1"] = "不灭东吴，誓不归蜀！",
  ["$sk__chouxi2"] = "害我兄弟之仇，不共戴天！",
  ["~sk_sr__liubei"] = "云长，翼德，久等了……",
}

local guanyu = General(extension, "sk_sr__guanyu", "shu", 4)
local sk__wenjiu = fk.CreateActiveSkill{
  name = "sk__wenjiu",
  anim_type = "offensive",
  card_num = 0,
  target_num = 0,
  prompt = "#sk__wenjiu",
  derived_piles = "sk__wenjiu",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local card = room:getNCards(1)
    local color = Fk:getCardById(card[1]).color
    player:addToPile(self.name, card, true, self.name, player.id)
    if player.dead or player:prohibitDiscard(Fk:cloneCard("slash")) then return end
    local use = U.askForUseVirtualCard(room, player, "slash", nil, self.name, "#sk__wenjiu-use", false, true, false, true, nil, true)
    if use then
      if color == Card.Black and #player:getPile(self.name) > 0 then
        use.additionalDamage = (use.additionalDamage or 0) + #player:getPile(self.name)
        room:moveCardTo(player:getPile(self.name), Card.DiscardPile, nil, fk.ReasonJustMove, self.name, nil, true, player.id)
      end
      room:useCard(use)
      if color == Card.Red and not use.damageDealt and not player.dead and #player:getPile(self.name) > 0 then
        room:moveCardTo(player:getPile(self.name), Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
      end
    end
  end,
}
local sk__shuixi = fk.CreateTriggerSkill{
  name = "sk__shuixi",
  anim_type = "offensive",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to, card = room:askForChooseCardAndPlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1,
      ".|.|.|hand", "#sk__shuixi-choose", self.name, true)
    if #to > 0 and card then
      self.cost_data = {to[1], card}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data[1])
    local suit = Fk:getCardById(self.cost_data[2]):getSuitString(true)
    player:showCards(self.cost_data[2])
    if to.dead then return end
    if player.dead or suit == "log_nosuit" then
      room:loseHp(to, 1, self.name)
      return
    end
    local all_choices = {"sk__shuixi_discard:::"..suit, "loseHp"}
    local choices = table.simpleClone(all_choices)
    local cards = table.filter(to:getCardIds("he"), function (id)
      return Fk:getCardById(id):getSuitString(true) == suit
    end)
    if #cards == 0 then
      table.remove(choices, 1)
    end
    local choice = room:askForChoice(to, choices, self.name, nil, false, all_choices)
    if choice == "loseHp" then
      room:loseHp(to, 1, self.name)
    else
      to:showCards(to:getCardIds("h"))
      if to.dead then return end
      cards = table.filter(cards, function (id)
        return Fk:getCardById(id):getSuitString(true) == suit and table.contains(to:getCardIds("he"), id)
      end)
      if #cards > 0 then
        room:throwCard(cards, self.name, to, to)
      end
    end
  end,
}
guanyu:addSkill(sk__wenjiu)
guanyu:addSkill(sk__shuixi)
Fk:loadTranslationTable{
  ["sk_sr__guanyu"] = "关羽",
  ["#sk_sr__guanyu"] = "忠义神武",

  ["sk__wenjiu"] = "温酒",
  [":sk__wenjiu"] = "出牌阶段限一次，你可以将牌堆顶牌置于武将牌上，称为“酒”，然后视为使用一张【杀】，若此“酒”颜色为：黑色，此【杀】伤害+X"..
  "（X为“酒”数），然后将所有“酒”置入弃牌堆；红色，若此【杀】未造成伤害，你获得所有“酒”。",
  ["sk__shuixi"] = "水袭",
  [":sk__shuixi"] = "准备阶段，你可以展示一张手牌并选择一名其他角色，其选择一项：1.展示所有手牌，弃置所有与你展示牌花色相同的牌（至少一张）；"..
  "2.失去1点体力。",
  ["#sk__wenjiu"] = "温酒：将牌堆顶牌置为“酒”，视为使用一张【杀】，根据“酒”的颜色附加效果",
  ["#sk__wenjiu-use"] = "温酒：请视为使用【杀】",
  ["#sk__shuixi-choose"] = "水袭：展示一张手牌，令一名角色选择弃牌或失去体力",
  ["sk__shuixi_discard"] = "展示手牌，弃置所有%arg牌",

  ["$sk__wenjiu1"] = "关某愿取其首级，献于帐下。",
  ["$sk__wenjiu2"] = "酒且放下，关某去去就来。",
  ["$sk__shuixi"] = "听听这江河的咆哮吧！",
  ["~sk_sr__guanyu"] = "必将尽行大义，以示后人。",
 }

local zhangfei = General(extension, "sk_sr__zhangfei", "shu", 4)
local sk__xujin = fk.CreateTriggerSkill{
  name = "sk__xujin",
  anim_type = "drawcard",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Draw
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:getNCards(5)
    room:moveCardTo(cards, Card.Processing, nil, fk.ReasonJustMove, self.name, nil, true, player.id)
    local to = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, 1,
      "#sk__xujin-choose", self.name, false)
    to = room:getPlayerById(to[1])
    local suits = {}
    for _, id in ipairs(cards) do
      table.insertIfNeed(suits, Fk:getCardById(id):getSuitString(true))
    end
    local _, choice = U.askforChooseCardsAndChoice(player, cards, suits, self.name, "#sk__xujin-get", nil, 0, 0, cards)
    local obtain, discard = {}, {}
    for _, id in ipairs(cards) do
      if Fk:getCardById(id):getSuitString(true) == choice then
        table.insert(obtain, id)
      else
        table.insert(discard, id)
      end
    end
    room:moveCardTo(obtain, Card.PlayerHand, to, fk.ReasonJustMove, self.name, nil, true, to.id)
    if #discard > 0 then
      room:moveCardTo(discard, Card.DiscardPile, nil, fk.ReasonJustMove, self.name, nil, true, player.id)
    end
    if not player.dead then
      room:setPlayerMark(player, "sk__xujin-turn", #obtain)
      room:addPlayerMark(player, MarkEnum.SlashResidue.."-turn", #obtain)
    end
    return true
  end,
}
local sk__xujin_attackrange = fk.CreateAttackRangeSkill{
  name = "#sk__xujin_attackrange",
  correct_func = function (self, from, to)
    return from:getMark("sk__xujin-turn")
  end,
}
local sk__paoxiao = fk.CreateTriggerSkill{
  name = "sk__paoxiao",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.Damage},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, self.name)
    if player.dead then return end
    local use = room:askForUseCard(player, "slash", nil)
    if use then
      use.extraUse = true
      room:useCard(use)
    else
      room:askForDiscard(player, 1, 1, true, self.name, false)
    end
  end,
}
sk__xujin:addRelatedSkill(sk__xujin_attackrange)
zhangfei:addSkill(sk__xujin)
zhangfei:addSkill(sk__paoxiao)
Fk:loadTranslationTable{
  ["sk_sr__zhangfei"] = "张飞",
  ["#sk_sr__zhangfei"] = "豪迈勇者",

  ["sk__xujin"] = "蓄劲",
  [":sk__xujin"] = "摸牌阶段，你可以放弃摸牌，改为亮出牌堆顶五张牌，令一名角色选择获得其中一种花色的牌，将其余牌置入弃牌堆，若如此做，你本回合"..
  "攻击范围和使用【杀】次数上限+X（X为目标角色以此法获得的牌数）。",
  ["sk__paoxiao"] = "咆哮",
  [":sk__paoxiao"] = "锁定技，当你使用【杀】造成伤害后，你摸一张牌，然后使用一张【杀】或弃置一张牌。",
  ["#sk__xujin-choose"] = "蓄劲：令一名角色获得其中的牌",
  ["#sk__xujin-get"] = "蓄劲：获得其中一种花色的牌",

  ["$sk__xujin"] = "休想逃！乖乖受死！",
  ["$sk__paoxiao"] = "都站稳了！吃我一击！",
  ["~sk_sr__zhangfei"] = "你这家伙，好生厉害！",
}

local zhaoyun = General(extension, "sk_sr__zhaoyun", "shu", 4)
local sk__jiuzhu = fk.CreateTriggerSkill{
  name = "sk__jiuzhu",
  anim_type = "offensive",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and not player:isNude() then
      local ids = {}
      for _, move in ipairs(data) do
        if move.toArea == Card.DiscardPile then
          for _, info in ipairs(move.moveInfo) do
            if Fk:getCardById(info.cardId).trueName == "jink" and table.contains(player.room.discard_pile, info.cardId) then
              table.insertIfNeed(ids, info.cardId)
            end
          end
        end
      end
      ids = U.moveCardsHoldingAreaCheck(player.room, ids)
      if #ids > 0 then
        self.cost_data = ids
        return true
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if #self.cost_data == 1 then
      local card = room:askForCard(player, 1, 1, true, self.name, true, "^jink",
        "#sk__jiuzhu-invoke:::"..Fk:getCardById(self.cost_data[1]):toLogString())
      if #card > 0 then
        self.cost_data = {card, self.cost_data}
        return true
      end
    else
      local cards = table.filter(player:getCardIds("he"), function (id)
        return Fk:getCardById(id).trueName ~= "jink"
      end)
      local results = U.askForExchange(player, "pile_discard", "hand_card", self.cost_data, cards, "#sk__jiuzhu-exchange", 999, true)
      if #results > 0 then
        self.cost_data = {table.filter(results, function(id)
          return table.contains(cards, id)
        end), table.filter(results, function(id)
          return table.contains(self.cost_data, id)
        end)}
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    U.swapCardsWithPile(player, self.cost_data[1], self.cost_data[2], self.name, "discardPile", true, player.id)
    if not player.dead then
      local room = player.room
      local turn_event = room.logic:getCurrentEvent():findParent(GameEvent.Turn)
      if not turn_event then return end
      if player.phase == Player.NotActive and room.current and not room.current.dead and
        not player:isProhibited(room.current, Fk:cloneCard("slash")) and
        room:askForSkillInvoke(player, self.name, nil, "#sk__jiuzhu-slash::"..room.current.id) then
        room:useVirtualCard("slash", nil, player, room.current, self.name, true)
      end
    end
  end,
}
local sk__jiuzhu_trigger = fk.CreateTriggerSkill{
  name = "#sk__jiuzhu_trigger",

  refresh_events = {fk.TargetSpecified},
  can_refresh = function(self, event, target, player, data)
    return target == player and table.contains(data.card.skillNames, "sk__jiuzhu")
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(data.to)
    local use_event = room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)
    if use_event == nil then return end
    room:addPlayerMark(to, fk.MarkArmorNullified)
    use_event:addCleaner(function()
      room:removePlayerMark(to, fk.MarkArmorNullified)
    end)
  end,
}
local sk__tuwei = fk.CreateTriggerSkill{
  name = "sk__tuwei",
  anim_type = "control",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and data.card.trueName == "slash" and not player:isNude() then
      if target == player then
        return true
      else
        return table.contains(TargetGroup:getRealTargets(data.tos), player.id)
      end
    end
  end,
  on_cost = function (self,event, target, player, data)
    local cards = player.room:askForDiscard(player, 1, 1, true, self.name, true, ".", "#sk__tuwei-invoke", true)
    if #cards > 0 then
      self.cost_data = cards
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard(self.cost_data, self.name, player, player)
    if player.dead then return end
    if target == player then
      room:doIndicate(player.id, TargetGroup:getRealTargets(data.tos))
      for _, id in ipairs(TargetGroup:getRealTargets(data.tos)) do
        if player.dead then return end
        local to = room:getPlayerById(id)
        if not to.dead and not to:isNude() then
          local cards = room:askForCardsChosen(player, to, 1, 2, "he", self.name, "#sk__tuwei-discard::"..id)
          room:throwCard(cards, self.name, to, player)
        end
      end
    else
      if not target.dead and not target:isNude() then
        room:doIndicate(player.id, {target.id})
        local cards = room:askForCardsChosen(player, target, 1, 2, "he", self.name, "#sk__tuwei-discard::"..target.id)
        room:throwCard(cards, self.name, target, player)
      end
    end
  end,
}
sk__jiuzhu:addRelatedSkill(sk__jiuzhu_trigger)
zhaoyun:addSkill(sk__jiuzhu)
zhaoyun:addSkill(sk__tuwei)
Fk:loadTranslationTable{
  ["sk_sr__zhaoyun"] = "赵云",
  ["#sk_sr__zhaoyun"] = "银龙逆鳞",

  ["sk__jiuzhu"] = "救主",
  [":sk__jiuzhu"] = "当一张【闪】进入弃牌堆后，你可以用一张不为【闪】的牌替换之。若不为你的回合，你可以视为对当前回合角色使用一张"..
  "无视防具的【杀】。",
  ["sk__tuwei"] = "突围",
  [":sk__tuwei"] = "当你使用【杀】或其他角色对你使用【杀】结算后，你可以弃置一张牌，然后弃置对方两张牌。",
  ["#sk__jiuzhu-invoke"] = "救主：是否用一张牌替换进入弃牌堆的%arg？",
  ["#sk__jiuzhu-exchange"] = "救主：你可以用不为【闪】的牌替换这些【闪】",
  ["#sk__jiuzhu-slash"] = "救主：是否视为对 %dest 使用一张无视防具的【杀】？",
  ["#sk__tuwei-invoke"] = "突围：你可以弃置一张牌，然后弃置对方两张牌",
  ["#sk__tuwei-discard"] = "突围：弃置 %dest 两张牌",

  ["$sk__jiuzhu"] = "和我一起，活着离开此地！",
  ["$sk__tuwei"] = "让我了结此阵！",
  ["~sk_sr__zhaoyun"] = "人外有人，子龙领教了。",
}

local machao = General(extension, "sk_sr__machao", "shu", 4)
local sk__benxi = fk.CreateTriggerSkill{
  name = "sk__benxi",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(data.to)
    if #room:askForDiscard(to, 1, 1, true, self.name, true, ".|.|.|.|.|equip", "#sk__benxi-discard") == 0 then
      data.disresponsive = true
    end
  end,
}
local sk__benxi_distance = fk.CreateDistanceSkill{
  name = "#sk__benxi_distance",
  frequency = Skill.Compulsory,
  main_skill = sk__benxi,
  correct_func = function(self, from, to)
    if from:hasSkill(self) then
      return -1
    end
    return 0
  end,
}
local sk__yaozhan = fk.CreateActiveSkill{
  name = "sk__yaozhan",
  anim_type = "offensive",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__yaozhan",
  can_use = function(self, player)
    return not player:isKongcheng() and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0 and to_select ~= player.id and player:canPindian(Fk:currentRoom():getPlayerById(to_select))
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local pindian = player:pindian({target}, self.name)
    if pindian.results[target.id].winner == player then
      if not target.dead then
        room:useVirtualCard("slash", nil, player, target, self.name, true)
      end
    elseif not player.dead and not target.dead then
      local use = room:askForUseCard(target, "slash", "slash", "#sk__yaozhan-use:"..player.id, true,
        {exclusive_targets = {player.id}, bypass_times = true})
      if use then
        room:useCard(use)
      end
    end
  end,
}
sk__benxi:addRelatedSkill(sk__benxi_distance)
machao:addSkill(sk__benxi)
machao:addSkill(sk__yaozhan)
Fk:loadTranslationTable{
  ["sk_sr__machao"] = "马超",
  ["#sk_sr__machao"] = "苍穹锦狮",

  ["sk__benxi"] = "奔袭",
  [":sk__benxi"] = "锁定技，你与其他角色的距离-1。当你使用【杀】指定一个目标后，其需弃置一张装备牌，否则此【杀】不能被响应。",
  ["sk__yaozhan"] = "邀战",
  [":sk__yaozhan"] = "出牌阶段限一次，你可以与一名角色拼点：若你赢，视为你对其使用一张【杀】；若你没赢，其可以对你使用一张【杀】。",
  ["#sk__benxi-discard"] = "奔袭：请弃置一张装备牌，否则不能被响应此【杀】",
  ["#sk__yaozhan"] = "邀战：与一名角色拼点，若你赢，视为对其使用【杀】；若没赢，其可以对你使用一张【杀】",
  ["#sk__yaozhan-use"] = "邀战：你可以对 %src 使用一张【杀】",

  ["$sk__benxi"] = "全军突击！",
  ["$sk__yaozhan"] = "堂堂正正地打一场吧！",
  ["~sk_sr__machao"] = "可恶，绝不轻饶……",
}

local zhugeliang = General(extension, "sk_sr__zhugeliang", "shu", 3)
local sk__sanfen = fk.CreateActiveSkill{
  name = "sk__sanfen",
  anim_type = "control",
  card_num = 0,
  target_num = 2,
  prompt = function (self, selected_cards, selected_targets)
    if #selected_targets == 0 then
      return "#sk__sanfen0"
    elseif #selected_targets == 1 then
      return "#sk__sanfen1:"..selected_targets[1]
    elseif #selected_targets == 2 then
      return "#sk__sanfen2:"..selected_targets[1]..":"..selected_targets[2]
    end
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected < 2 and to_select ~= player.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target1 = room:getPlayerById(effect.tos[1])
    local target2 = room:getPlayerById(effect.tos[2])
    local yes = false
    local use = room:askForUseCard(target1, "slash", "slash",
      "#sk__sanfen-use::"..target2.id, true, {exclusive_targets = {target2.id}})
    if use then
      room:useCard(use)
    else
      yes = true
    end
    if not target2.dead then
      room:delay(800)
      use = room:askForUseCard(target2, "slash", "slash",
        "#sk__sanfen-use::"..player.id, true, {exclusive_targets = {player.id}})
      if use then
        room:useCard(use)
      else
        yes = true
      end
    else
      yes = true
    end
    if not player.dead and not target1.dead and not player:isProhibited(target1, Fk:cloneCard("slash")) then
      room:delay(800)
      room:useVirtualCard("slash", nil, player, target1, self.name, true)
    else
      yes = true
    end
    if yes then
      for _, p in ipairs({target1, target2}) do
        if not player.dead and not p.dead and not p:isNude() then
          room:delay(800)
          local card = room:askForCardChosen(player, p, "he", self.name, "#sk__sanfen-discard::"..p.id)
          room:throwCard({card}, self.name, p, player)
        end
      end
    end
  end
}
local sk__weiwo = fk.CreateTriggerSkill{
  name = "sk__weiwo",
  anim_type = "defensive",
  frequency = Skill.Compulsory,
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) then
      if data.damageType == fk.NormalDamage then
        return player:isKongcheng()
      else
        return not player:isKongcheng()
      end
    end
  end,
  on_use = Util.TrueFunc,
}
zhugeliang:addSkill(sk__sanfen)
zhugeliang:addSkill(sk__weiwo)
zhugeliang:addSkill("ex__guanxing")
Fk:loadTranslationTable{
  ["sk_sr__zhugeliang"] = "诸葛亮",
  ["#sk_sr__zhugeliang"] = "三分天下",

  ["sk__sanfen"] = "三分",
  [":sk__sanfen"] = "出牌阶段限一次，你可以选择两名其他角色，第一名角色需对第二名角色使用【杀】，第二名角色需对你使用【杀】，你视为对第一名"..
  "角色使用【杀】。若有未使用的【杀】，你弃置这两名角色各一张牌。",
  ["sk__weiwo"] = "帷幄",
  [":sk__weiwo"] = "锁定技，当你受到属性伤害时，若你有手牌；或当你受到非属性伤害时，若你没有手牌：你防止此伤害。",
  ["#sk__sanfen0"] = "三分：选择一名角色，其需对第二名角色使用【杀】，你视为对其使用【杀】",
  ["#sk__sanfen1"] = "三分：选择一名角色，%src 需对其使用【杀】，其需对你使用【杀】",
  ["#sk__sanfen2"] = "三分：%src 需对 %dest 使用【杀】，%dest 需对你使用【杀】，你视为对 %src 使用【杀】",
  ["#sk__sanfen-use"] = "三分：请对 %dest 使用一张【杀】",
  ["#sk__sanfen-discard"] = "三分：弃置 %dest 一张牌",

  ["$sk__sanfen"] = "诚如是，则汉室可兴矣。",
  ["$ex__guanxing_sk_sr__zhugeliang"] = "知天易，逆天难。",
  ["$sk__weiwo"] = "挫敌锐气，静待反击之时。",
  ["~sk_sr__zhugeliang"] = "悠悠苍天，曷此其极？",
}

local huangyueying = General(extension, "sk_sr__huangyueying", "shu", 3, 3, General.Female)
local SrYueyingMapper = function (id)
  local suit = Fk:getCardById(id, true).suit
  local mapper = {
    [Card.Spade] = "duel",
    [Card.Club] = "collateral",
    [Card.Heart] = "snatch",
    [Card.Diamond] = "fire_attack",
    [Card.NoSuit] = "",
  }
  return mapper[suit]
end
local sk__shouji = fk.CreateActiveSkill{
  name = "sk__shouji",
  anim_type = "control",
  prompt = function (self, selected_cards, selected_targets)
    if #selected_cards == 0 then
      return "#sk__shouji"
    elseif #selected_cards == 1 then
      local card = Fk:cloneCard(SrYueyingMapper(selected_cards[1]))
      if #selected_targets == 0 then
        return "#sk__shouji1:::"..card.name
      elseif #selected_targets == 1 then
        return "#sk__shouji2:"..selected_targets[1].."::"..card.name
      elseif #selected_targets == 2 then
        return "#sk__shouji3:"..selected_targets[1]..":"..selected_targets[2]..":"..card.name
      end
    end
  end,
  card_num = 1,
  target_num = 2,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, to_select, selected,player)
    return #selected == 0 and not player:prohibitDiscard(to_select)
  end,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    if #selected < 2 and #selected_cards == 1 then
      local card = Fk:cloneCard(SrYueyingMapper(selected_cards[1]))
      card.skillName = self.name
      local target = Fk:currentRoom():getPlayerById(to_select)
      if #selected == 0 then
        return target:canUse(card, {bypass_distances = true}) and not target:prohibitUse(card)
      elseif #selected == 1 then
        return Fk:currentRoom():getPlayerById(selected[1]):canUseTo(card, target, {bypass_distances = true})
      end
    end
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local src = room:getPlayerById(effect.tos[1])
    local target = room:getPlayerById(effect.tos[2])
    room:throwCard(effect.cards, self.name, player, player)
    local card = Fk:cloneCard(SrYueyingMapper(effect.cards[1]))
    card.skillName = self.name
    if card.name == "collateral" then
      local targets = table.filter(Fk:currentRoom().alive_players, function (p)
        return target ~= p and target:inMyAttackRange(p)
      end)
      local to = src.id
      if #targets > 0 then
        to = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1,
          "#sk__shouji-collateral:"..src.id..":"..target.id, self.name, false)[1]
      end
      local use = {
        from = src.id,
        tos = {{target.id}, {to}},
        card = card,
      }
      room:useCard(use)
    else
      room:useVirtualCard(card.name, nil, src, target, self.name)
    end
  end,
}
local sk__hemou = fk.CreateTriggerSkill{
  name = "sk__hemou",
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(self) and target.phase == Player.Play and not target.dead and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForCard(player, 1, 1, false, self.name, true, ".", "#sk__hemou-invoke::"..target.id)
    if #card > 0 then
      self.cost_data = card[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    room:moveCardTo(self.cost_data, Card.PlayerHand, target, fk.ReasonGive, self.name, nil, false, player.id)
    if not target.dead then
      room:setPlayerMark(target, "sk__hemou-phase", self.cost_data)
      room:handleAddLoseSkills(target, "sk__hemou&", nil, false, true)
      local phase_event = room.logic:getCurrentEvent():findParent(GameEvent.Phase)
      if phase_event ~= nil then
        phase_event:addCleaner(function()
          room:handleAddLoseSkills(target, "-sk__hemou&", nil, false, true)
        end)
      end
    end
  end,
}
local sk__hemou_active = fk.CreateViewAsSkill{
  name = "sk__hemou&",
  anim_type = "special",
  prompt = function (self, selected, selected_cards)
    return "#sk__hemou:::"..Fk:getCardById(Self:getMark("sk__hemou-phase"), true):getSuitString(true)..":"..
      SrYueyingMapper(Self:getMark("sk__hemou-phase"))
  end,
  card_filter = function(self, to_select, selected,player)
    return #selected == 0 and Fk:getCardById(to_select).suit == Fk:getCardById(player:getMark("sk__hemou-phase"), true).suit and
      Fk:currentRoom():getCardArea(to_select) ~= Card.PlayerEquip
  end,
  view_as = function(self, cards,player)
    if #cards ~= 1 then return end
    local card = Fk:cloneCard(SrYueyingMapper(player:getMark("sk__hemou-phase")))
    card.skillName = "sk__hemou"
    card:addSubcards(cards)
    return card
  end,
  enabled_at_play = function (self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 and player:getMark("sk__hemou-phase") ~= 0
  end,
  enabled_at_response = Util.FalseFunc,
}
local sk__qicai = fk.CreateTriggerSkill{
  name = "sk__qicai",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      for _, move in ipairs(data) do
        if move.from == player.id then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand then
              return true
            end
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local judge = {
      who = player,
      reason = self.name,
      pattern = ".|.|heart,diamond",
    }
    room:judge(judge)
    if not player.dead and judge.card.color == Card.Red then
      player:drawCards(1, self.name)
    end
  end,
}
Fk:addSkill(sk__hemou_active)
huangyueying:addSkill(sk__shouji)
huangyueying:addSkill(sk__hemou)
huangyueying:addSkill(sk__qicai)
Fk:loadTranslationTable{
  ["sk_sr__huangyueying"] = "黄月英",
  ["#sk_sr__huangyueying"] = "灵智共鸣",

  ["sk__shouji"] = "授计",
  [":sk__shouji"] = "出牌阶段限一次，你可以弃置一张牌并选择两名角色，根据此牌的花色，视为第一名角色对第二名角色使用一张锦囊牌：<br>"..
  "♠-【决斗】；♣-【借刀杀人】；<br><font color='red'>♥</font>-【顺手牵羊】；<font color='red'>♦</font>-【火攻】。",
  ["sk__hemou"] = "合谋",
  [":sk__hemou"] = "其他角色出牌阶段开始时，你可以交给其一张手牌，若如此做，该角色此出牌阶段限一次，根据此牌的花色，其可以将一张此花色的手牌"..
  "当对应的锦囊使用：<br>♠-【决斗】；♣-【借刀杀人】；<br><font color='red'>♥</font>-【顺手牵羊】；<font color='red'>♦</font>-【火攻】。",
  ["sk__qicai"] = "奇才",
  [":sk__qicai"] = "锁定技，当你失去手牌后，你判定，若为红色，你摸一张牌。",
  ["#sk__shouji"] = "授计：弃置一张牌，根据花色视为一名角色对另一名角色使用锦囊<br>"..
  "♠【决斗】；♣【借刀杀人】；<font color='red'>♥</font>【顺手牵羊】；<font color='red'>♦</font>【火攻】",
  ["#sk__shouji1"] = "授计：选择视为使用【%arg】的使用者",
  ["#sk__shouji2"] = "授计：选择视为 %src 使用【%arg】的目标",
  ["#sk__shouji3"] = "授计：视为 %src 对 %dest 使用【%arg】",
  ["#sk__shouji-collateral"] = "授计：选择视为 %src 对 %dest 使用【借刀杀人】的副目标",
  ["#sk__hemou-invoke"] = "合谋：你可以交给 %dest 一张手牌，其本阶段可以将一张此牌花色的手牌转化锦囊使用<br>"..
  "♠【决斗】；♣【借刀杀人】；<font color='red'>♥</font>【顺手牵羊】；<font color='red'>♦</font>【火攻】",
  ["sk__hemou&"] = "合谋",
  [":sk__hemou&"] = "出牌阶段限一次，你可以将一张特定花色的手牌当对应的锦囊使用：<br>♠-【决斗】；♣-【借刀杀人】；<br>"..
  "<font color='red'>♥</font>-【顺手牵羊】；<font color='red'>♦</font>-【火攻】。",
  ["#sk__hemou"] = "合谋：你可以将一张%arg手牌当【%arg2】使用",

  ["$sk__shouji"] = "还记得我给你的锦囊吗？",
  ["$sk__hemou"] = "一起渡过这道难关吧。",
  ["$sk__qicai"] = "尽在我们掌握之中。",
  ["~sk_sr__huangyueying"] = "孔明大人，请一定要赢……",
}

local sr_sunquan = General(extension, "sk_sr__sunquan", "wu", 4)
local sk__quanheng = fk.CreateViewAsSkill{
  name = "sk__quanheng",
  prompt = "#sk__quanheng",
  interaction = function()
    return UI.ComboBox {choices = {"ex_nihilo", "slash"}}
  end,
  card_filter = function (self, to_select, selected,player)
    return Fk:currentRoom():getCardArea(to_select) ~= Card.PlayerEquip
  end,
  view_as = function(self, cards,player)
    if #cards == 0 or not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = self.name
    card:addSubcards(cards)
    return card
  end,
  before_use = function (self, player, use)
    use.extraUse = true
    use.extra_data = use.extra_data or {}
    use.extra_data.sk__quanheng = {player.id, #use.card.subcards}
  end,
  enabled_at_play = function (self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
}
local sk__quanheng_delay = fk.CreateTriggerSkill{
  name = "#sk__quanheng_delay",
  mute = true,
  events = {fk.CardEffectCancelledOut},
  can_trigger = function(self, event, target, player, data)
    return target == player and not player.dead and data.extra_data and data.extra_data.sk__quanheng and
      data.extra_data.sk__quanheng[1] == player.id
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:drawCards(data.extra_data.sk__quanheng[2], "sk__quanheng")
  end,
}
local sk__xionglve = fk.CreateActiveSkill{
  name = "sk__xionglve",
  anim_type = "special",
  expand_pile = "sk_sr__sunquan_lve",
  derived_piles = "sk_sr__sunquan_lve",
  prompt = "#sk__xionglve",
  card_num = 1,
  can_use =function (self, player, card, extra_data)
    return #player:getPile("sk_sr__sunquan_lve") > 0
  end,
  interaction = function(self,player)
    local all_names = U.getAllCardNames("bt")
    local names = U.getViewAsCardNames(player, self.name, all_names)
    return U.CardNameBox { choices = names, all_choices = all_names }
  end,
  card_filter = function(self, to_select, selected,player)
    if #selected == 0 and player:getPileNameOfId(to_select) == "sk_sr__sunquan_lve" then
      local card = Fk:getCardById(to_select)
      if card.type == Card.TypeEquip then
        return true
      else
        return card.type == Fk:cloneCard(self.interaction.data).type
      end
    end
  end,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    if #selected_cards > 0 and self.interaction.data then
      if Fk:getCardById(selected_cards[1]).type == Card.TypeEquip then
        return #selected == 0 and #selected_cards == 1 and to_select ~= player.id and
          U.canMoveCardIntoEquip(Fk:currentRoom():getPlayerById(to_select), selected_cards[1], false)
      else
        local card = Fk:cloneCard(self.interaction.data)
        card.skillName = self.name
        if card.skill:getMinTargetNum() == 0 then
          return false
        else
          return card.skill:targetFilter(to_select, selected, selected_cards, card)
        end
      end
    end
  end,
  feasible = function(self, selected, selected_cards,player)
    if #selected_cards > 0 and self.interaction.data then
      if Fk:getCardById(selected_cards[1]).type == Card.TypeEquip then
        return #selected_cards == 1 and #selected == 1
      else
        local card = Fk:cloneCard(self.interaction.data)
        card.skillName = self.name
        card:addSubcards(selected_cards)
        if player:canUse(card) and not player:prohibitUse(card) then
          return #selected_cards == 1 and card.skill:feasible(selected, selected_cards, player, card)
        end
      end
    end
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    if Fk:getCardById(effect.cards[1]).type == Card.TypeEquip then
      local target = room:getPlayerById(effect.tos[1])
      U.moveCardIntoEquip(room, target, effect.cards[1], self.name, true, player)
    else
      local use = {
        from = player.id,
        tos = table.map(effect.tos, function (id) return {id} end),
        card = Fk:cloneCard(self.interaction.data),
      }
      use.card:addSubcards(effect.cards)
      use.card.skillName = self.name
      room:useCard(use)
    end
  end,
}
local sk__xionglve_trigger = fk.CreateTriggerSkill{
  name = "#sk__xionglve_trigger",
  mute = true,
  main_skill = sk__xionglve,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk__xionglve) and player.phase == Player.Draw
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askForSkillInvoke(player, "sk__xionglve")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("sk__xionglve")
    room:notifySkillInvoked(player, "sk__xionglve", "special")
    local cards = room:getNCards(2)
    room:moveCardTo(cards, Card.Processing, nil, fk.ReasonJustMove, "sk__xionglve", nil, true, player.id)
    cards = table.filter(cards, function (id)
      return room:getCardArea(id) == Card.Processing
    end)
    if #cards == 0 then return end
    if player.dead then
      room:moveCardTo(cards, Card.DiscardPile, nil, fk.ReasonJustMove, "sk__xionglve", nil, true)
      return
    end
    local card, _ = U.askforChooseCardsAndChoice(player, cards, {"OK"},
      "sk__xionglve", "#sk__xionglve-get", {}, 1, 1)
    room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonJustMove, "sk__xionglve", nil, true, player.id)
    cards = table.filter(cards, function (id)
      return room:getCardArea(id) == Card.Processing
    end)
    if #cards == 0 then return end
    if player.dead then
      room:moveCardTo(cards, Card.DiscardPile, nil, fk.ReasonJustMove, "sk__xionglve", nil, true)
      return
    end
    player:addToPile("sk_sr__sunquan_lve", cards, true, "sk__xionglve", player.id)
    return true
  end,
}
sk__quanheng:addRelatedSkill(sk__quanheng_delay)
sk__xionglve:addRelatedSkill(sk__xionglve_trigger)
sr_sunquan:addSkill(sk__quanheng)
sr_sunquan:addSkill(sk__xionglve)
Fk:loadTranslationTable{
  ["sk_sr__sunquan"] = "孙权",
  ["#sk_sr__sunquan"] = "东吴大帝",

  ["sk__quanheng"] = "权衡",
  [":sk__quanheng"] = "出牌阶段限一次，你可以将任意张手牌当一张【无中生有】或【杀】使用，当你以此法使用的牌被抵消时，你摸X张牌"..
  "（X为用于转化的牌数）。",
  ["sk__xionglve"] = "雄略",
  [":sk__xionglve"] = "摸牌阶段，你可以放弃摸牌，改为亮出牌堆顶的两张牌，你获得其中一张牌，然后将另一张牌置于你的武将牌上，称为“略”。<br>"..
  "出牌阶段，你可以将类别为基本牌的“略”当任意基本牌使用，将类别为锦囊牌的“略”当任意普通锦囊牌使用，将类别为装备牌的“略”置入其他角色的装备区。",
  ["#sk__quanheng"] = "权衡：将任意张手牌当一张【无中生有】或【杀】使用",
  ["#sk__xionglve"] = "雄略：将一张基本牌或锦囊牌“略”当同类别牌使用；将一张装备牌“略”置入其他角色的装备区",
  ["#sk__xionglve_trigger"] = "雄略",
  ["#sk__xionglve-get"] = "雄略：获得其中一张牌，另一张置为“略”",
  ["sk_sr__sunquan_lve"] = "略",

  ["$sk__quanheng"] = "容我三思。",
  ["$sk__xionglve1"] = "识大体，弃细务，此乃君道。",
  ["$sk__xionglve2"] = "知己长短，方能避短就长。",
  ["~sk_sr__sunquan"] = "父亲，大哥，仲谋愧矣……",
}

local ganning = General(extension, "sk_sr__ganning", "wu", 4)
local sk__jiexi = fk.CreateActiveSkill{
  name = "sk__jiexi",
  anim_type = "control",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__jiexi",
  can_use = function(self, player)
    return not player:isKongcheng()
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0 and player:canPindian(Fk:currentRoom():getPlayerById(to_select))
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local pindian = player:pindian({target}, self.name)
    if pindian.results[target.id].winner == player and not player.dead and not target.dead and not target:isAllNude() then
      room:useVirtualCard("dismantlement", nil, player, target, self.name)
    end
  end,
}
local sk__youxia = fk.CreateActiveSkill{
  name = "sk__youxia",
  anim_type = "control",
  card_num = 0,
  min_target_num = 1,
  max_target_num = 2,
  prompt = "#sk__youxia",
  can_use = function(self, player)
    return player.faceup
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected < 2 and not Fk:currentRoom():getPlayerById(to_select):isNude() and to_select ~= player.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    player:turnOver()
    room:sortPlayersByAction(effect.tos)
    for _, id in ipairs(effect.tos) do
      local target = room:getPlayerById(id)
      if player.dead then return end
      if not target.dead and not target:isNude() then
        local card = room:askForCardChosen(player, target, "hej", self.name, "#sk__youxia-prey::"..id)
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, false, player.id)
      end
    end
  end,
}
local sk__youxia_prohibit = fk.CreateProhibitSkill{
  name = "#sk__youxia_prohibit",
  main_skill = sk__youxia,
  is_prohibited = function(self, from, to, card)
    if to:hasSkill(sk__youxia) and not to.faceup then
      return card.trueName == "slash" or card.trueName == "duel"
    end
  end,
}
sk__youxia:addRelatedSkill(sk__youxia_prohibit)
ganning:addSkill(sk__jiexi)
ganning:addSkill(sk__youxia)
Fk:loadTranslationTable{
  ["sk_sr__ganning"] = "甘宁",
  ["#sk_sr__ganning"] = "怀铃乌羽",

  ["sk__jiexi"] = "劫袭",
  [":sk__jiexi"] = "出牌阶段，你可以与一名角色拼点：若你赢，视为你对其使用【过河拆桥】。",
  ["sk__youxia"] = "游侠",
  [":sk__youxia"] = "出牌阶段，若你的武将牌正面朝上，你可以翻面，获得至多两名其他角色区域内各一张牌。若你的武将牌背面朝上，你不能成为【杀】"..
  "和【决斗】的目标。",
  ["#sk__jiexi"] = "劫袭：与一名角色拼点，若你赢，视为你对其使用【过河拆桥】",
  ["#sk__youxia"] = "游侠：你可以翻面，获得至多两名角色各一张牌",
  ["#sk__youxia-prey"] = "游侠：获得 %dest 区域内一张牌",

  ["$sk__jiexi"] = "伙计们，一口气拿下！",
  ["$sk__youxia1"] = "给我打他个措手不及！",
  ["$sk__youxia2"] = "这下要再不打，可就晚啦！",
  ["~sk_sr__ganning"] = "坏了，这下跑不了了！",
}

local lvmeng = General(extension, "sk_sr__lvmeng", "wu", 4)
local sk__shixue = fk.CreateTriggerSkill{
  name = "sk__shixue",
  anim_type = "drawcard",
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "slash" and data.firstTarget
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(2, self.name)
    data.extra_data = data.extra_data or {}
    data.extra_data.sk__shixue = player.id
  end,
}
local sk__shixue_delay = fk.CreateTriggerSkill{
  name = "#sk__shixue_delay",
  mute = true,
  events = {fk.CardEffectCancelledOut},
  can_trigger = function(self, event, target, player, data)
    if target == player and data.card.trueName == "slash" and not player:isNude() then
      local e = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)
      if e then
        local use = e.data[1]
        if use.extra_data and use.extra_data.sk__shixue and use.extra_data.sk__shixue == player.id then
          return true
        end
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("sk__shixue")
    room:notifySkillInvoked(player, "sk__shixue", "negative")
    room:askForDiscard(player, 2, 2, true, "sk__shixue", false)
  end,
}
local sk__guoshi = fk.CreateTriggerSkill{
  name = "sk__guoshi",
  anim_type = "control",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      if target.phase == Player.Start then
        return true
      elseif target.phase == Player.Finish and not target.dead then
        local turn_event = player.room.logic:getCurrentEvent():findParent(GameEvent.Turn, true)
        if turn_event == nil then return end
        return #player.room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function (e)
          for _, move in ipairs(e.data) do
            if move.moveReason == fk.ReasonDiscard or move.moveReason == fk.ReasonJudge then
              for _, info in ipairs(move.moveInfo) do
                if player.room:getCardArea(info.cardId) == Card.DiscardPile then
                  return true
                end
              end
            end
          end
        end, Player.HistoryTurn) > 0
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    if target.phase == Player.Start then
      return player.room:askForSkillInvoke(player, self.name)
    elseif target.phase == Player.Finish then
      return player.room:askForSkillInvoke(player, self.name, nil, "#sk__guoshi-invoke::"..target.id)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if target.phase == Player.Start then
      local result = room:askForArrangeCards(player, self.name, {room:getNCards(2), "Top", "Bottom"}, "#sk__guoshi", false, 0,
        {2, 2}, {0, 0})
      local top, bottom = result[1], result[2]
      for i = #top, 1, -1 do
        table.insert(room.draw_pile, 1, top[i])
      end
      for i = 1, #bottom, 1 do
        table.insert(room.draw_pile, bottom[i])
      end
      room:sendLog{
        type = "#GuanxingResult",
        from = player.id,
        arg = #top,
        arg2 = #bottom,
      }
    elseif target.phase == Player.Finish then
      local cards = {}
      room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function (e)
        for _, move in ipairs(e.data) do
          if move.moveReason == fk.ReasonDiscard or move.moveReason == fk.ReasonJudge then
            for _, info in ipairs(move.moveInfo) do
              if room:getCardArea(info.cardId) == Card.DiscardPile then
                table.insertIfNeed(cards, info.cardId)
              end
            end
          end
        end
      end, Player.HistoryTurn)
      cards = U.askforChooseCardsAndChoice(player, cards, {"OK"}, self.name, "#sk__guoshi-card::"..target.id, {}, 1, 1)
      room:moveCardTo(cards, Card.PlayerHand, target, fk.ReasonJustMove, self.name, nil, true, player.id)
    end
  end,
}
sk__shixue:addRelatedSkill(sk__shixue_delay)
lvmeng:addSkill(sk__shixue)
lvmeng:addSkill(sk__guoshi)
Fk:loadTranslationTable{
  ["sk_sr__lvmeng"] = "吕蒙",
  ["#sk_sr__lvmeng"] = "国士之风",

  ["sk__shixue"] = "誓学",
  [":sk__shixue"] = "当你使用【杀】指定目标后，你可以摸两张牌，若如此做，当此【杀】被目标角色使用【闪】抵消时，你弃置两张牌。",
  ["sk__guoshi"] = "国士",
  [":sk__guoshi"] = "一名角色准备阶段，你可以观看牌堆顶两张牌，将其中任意张牌置于牌堆底。一名角色结束阶段，你可以令其获得弃牌堆中一张"..
  "本回合因弃置或判定进入弃牌堆的牌。",
  ["#sk__guoshi"] = "国士：将任意张牌置于牌堆底",
  ["#sk__guoshi-invoke"] = "国士：是否令 %dest 获得一张本回合因弃置或判定进入弃牌堆的牌？",
  ["#sk__guoshi-card"] = "国士：选择令 %dest 获得的牌",

  ["$sk__shixue"] = "不经一事，不长一智。",
  ["$sk__guoshi1"] = "此事须从长计议。",
  ["$sk__guoshi2"] = "小不忍，则乱大谋。",
  ["~sk_sr__lvmeng"] = "大志难继，吾已无计可施……",
}

local huanggai = General(extension, "sk_sr__huanggai", "wu", 4)
local sk__zhouyan = fk.CreateActiveSkill{
  name = "sk__zhouyan",
  anim_type = "offensive",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__zhouyan",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    target:drawCards(1, self.name)
    if target.dead or not player:canUseTo(Fk:cloneCard("fire_attack"), target) then return end
    local use = room:useVirtualCard("fire_attack", nil, player, target, self.name)
    if not player.dead and not target.dead and use.damageDealt and
      room:askForSkillInvoke(player, self.name, nil, "#sk__zhouyan-invoke::"..target.id) then
        player:broadcastSkillInvoke(self.name)
        room:notifySkillInvoked(player, self.name)
        room:doIndicate(player.id, {target.id})
        self:onUse(room, {
          from = player.id,
          tos = {target.id},
        })
    end
  end,
}
local sk__zhouyan_trigger = fk.CreateTriggerSkill{
  name = "#sk__zhouyan_trigger",
  mute = true,
  main_skill = sk__zhouyan,
  events = {fk.Damage},
  can_trigger = function(self, event, target, player, data)
    return target and target == player and player:hasSkill(sk__zhouyan) and data.damageType == fk.FireDamage
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:broadcastSkillInvoke("sk__zhouyan")
    player.room:notifySkillInvoked(player, "sk__zhouyan", "drawcard")
    player:drawCards(1, "sk__zhouyan")
  end,
}
local sk__zhaxiang = fk.CreateActiveSkill{
  name = "sk__zhaxiang",
  anim_type = "offensive",
  card_num = 1,
  target_num = 1,
  prompt = "#sk__zhaxiang",
  can_use = function(self, player)
    return not player:isKongcheng()
  end,
  card_filter = function (self, to_select, selected,player)
    return #selected == 0 and Fk:currentRoom():getCardArea(to_select) == Card.PlayerHand
  end,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0 and to_select ~= player.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local card = effect.cards[1]
    room:moveCardTo(card, Card.Void, nil, fk.ReasonJustMove, self.name, nil, false, player.id)
    local cards = room:askForCard(target, 1, 1, true, self.name, true, ".", "#sk__zhaxiang-give:"..player.id)
    if #cards > 0 then
      room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, false, player.id)
      if player.dead then
        room:moveCardTo(card, Card.DiscardPile, nil, fk.ReasonJustMove, self.name, nil, true, nil)
      else
        room:moveCardTo(card, Card.DiscardPile, nil, fk.ReasonDiscard, self.name, nil, true, player.id)
      end
    else
      local yes = Fk:getCardById(card).trueName == "slash"
      room:moveCardTo(card, Card.PlayerHand, target, fk.ReasonJustMove, self.name, nil, true, player.id)
      if yes and not target.dead then
        room:useVirtualCard("fire__slash", nil, player, target, self.name, true)
      end
    end
  end,
}
sk__zhouyan:addRelatedSkill(sk__zhouyan_trigger)
huanggai:addSkill(sk__zhouyan)
huanggai:addSkill(sk__zhaxiang)
Fk:loadTranslationTable{
  ["sk_sr__huanggai"] = "黄盖",
  ["#sk_sr__huanggai"] = "舍命一搏",

  ["sk__zhouyan"] = "舟焰",
  [":sk__zhouyan"] = "出牌阶段限一次，你可以令一名角色摸一张牌，视为你对其使用【火攻】，若此【火攻】造成了伤害，你可以重复此流程。"..
  "当你造成火焰伤害后，你摸一张牌。",
  ["sk__zhaxiang"] = "诈降",
  [":sk__zhaxiang"] = "出牌阶段，你可以扣置一张手牌并选择一名其他角色，令其选择一项：1.交给你一张牌，你弃置扣置的牌；2.其获得你扣置的牌，"..
  "若为【杀】，视为你对其使用一张火【杀】。",
  ["#sk__zhouyan"] = "舟焰：令一名角色摸一张牌，视为对其使用【火攻】",
  ["#sk__zhouyan-invoke"] = "舟焰：是否继续对 %dest 发动“舟焰”？",
  ["#sk__zhaxiang"] = "诈降：扣置一张手牌，令一名角色选择交给你一张牌，或获得你扣置的牌",
  ["#sk__zhaxiang-give"] = "诈降：交给 %src 一张牌，或点“取消”获得其扣置的牌，若为【杀】，视为其对你使用火【杀】",

  ["$sk__zhouyan"] = "待老夫来会会你！",
  ["$sk__zhaxiang"] = "肝脑涂地，无以为报！",
  ["~sk_sr__huanggai"] = "这条老命，已是风中之烛……",
}

local zhouyu = General(extension, "sk_sr__zhouyu", "wu", 3)
local sk__yingcai = fk.CreateTriggerSkill{
  name = "sk__yingcai",
  anim_type = "drawcard",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Draw
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards, suits = {}, {}
    while #suits < 3 do
      local card = room:getNCards(1)[1]
      table.insert(cards, card)
      room:moveCardTo(card, Card.Processing, nil, fk.ReasonJustMove, self.name, nil, true, player.id)
      local suit = Fk:getCardById(card).suit
      if suit ~= Card.NoSuit then
        table.insertIfNeed(suits, suit)
        if #suits < 3 then
          room:setCardEmotion(card, "judgegood")
        else
          room:setCardEmotion(card, "judgebad")
          break
        end
      end
      room:delay(800)
    end
    room:delay(800)
    room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
    return true
  end,
}
local sk__choulve = fk.CreateActiveSkill{
  name = "sk__choulve",
  anim_type = "offensive",
  prompt = "#sk__choulve",
  card_num = 2,
  target_num = 2,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, to_select, selected,player)
    return #selected < 2 and Fk:currentRoom():getCardArea(to_select) == Card.PlayerHand
  end,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected < 2
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target1 = room:getPlayerById(effect.tos[1])
    local target2 = room:getPlayerById(effect.tos[2])
    local from, to = target1, target1
    if Fk:getCardById(effect.cards[1]).number > Fk:getCardById(effect.cards[2]).number then
      to = target2
    elseif Fk:getCardById(effect.cards[1]).number < Fk:getCardById(effect.cards[2]).number then
      from = target2
    end
    local moveInfos = {}
    for i = 1, 2, 1 do
      if effect.tos[i] ~= player.id then
        table.insert(moveInfos, {
          ids = {effect.cards[i]},
          from = player.id,
          to = effect.tos[i],
          toArea = Card.PlayerHand,
          moveReason = fk.ReasonGive,
          proposer = player.id,
          skillName = self.name,
          moveVisible = true,
        })
      end
    end
    if #moveInfos > 0 then
      room:moveCards(table.unpack(moveInfos))
    end
    if from ~= to and not to.dead then
      local use = room:useVirtualCard("slash", nil, from, to, self.name, true)
      if not player.dead and use.damageDealt then
        player:drawCards(1, self.name)
      end
    end
  end,
}
zhouyu:addSkill(sk__yingcai)
zhouyu:addSkill("ex__fanjian")
zhouyu:addSkill(sk__choulve)
Fk:loadTranslationTable{
  ["sk_sr__zhouyu"] = "周瑜",
  ["#sk_sr__zhouyu"] = "王佐之姿",

  ["sk__yingcai"] = "英才",
  [":sk__yingcai"] = "摸牌阶段，你可以放弃摸牌，改为重复亮出牌堆顶牌，直到以此法亮出三种花色的牌，然后你获得这些牌。",
  ["sk__choulve"] = "筹略",
  [":sk__choulve"] = "出牌阶段限一次，你可以交给两名角色各一张手牌，获得点数较大牌的角色视为对另一名角色使用一张【杀】，若此【杀】造成伤害，"..
  "你摸一张牌。",
  ["#sk__choulve"] = "筹略：交给两名角色各一张手牌，获得点数较大牌的角色视为对另一名角色使用【杀】<br>（选择牌的顺序和选择角色的顺序相同）",

  ["$sk__yingcai"] = "汝等看好了！",
  ["$ex__fanjian_sk_sr__zhouyu"] = "一步步走向绝境吧！",
  ["$sk__choulve"] = "一切如我所料！",
  ["~sk_sr__zhouyu"] = "谁高一筹，我心中有数……",
}

local daqiao = General(extension, "sk_sr__daqiao", "wu", 3, 3, General.Female)
local sk__fangxin = fk.CreateViewAsSkill{
  name = "sk__fangxin",
  anim_type = "support",
  pattern = "peach",
  prompt = "#sk__fangxin",
  card_filter = function(self, to_select, selected,player)
    if #selected == 0 then
      if Fk:getCardById(to_select).suit == Card.Diamond then
        return not player:hasDelayedTrick("indulgence")
      end
      if Fk:getCardById(to_select).suit == Card.Club then
        return not player:hasDelayedTrick("supply_shortage")
      end
    end
  end,
  view_as = function(self, cards,player)
    if #cards ~= 1 then return end
    local card = Fk:cloneCard("peach")
    card.skillName = self.name
    card:setMark(self.name, cards[1])
    return card
  end,
  before_use = function (self, player, use)
    local card
    if Fk:getCardById(use.card:getMark(self.name)).suit == Card.Diamond then
      card = Fk:cloneCard("indulgence")
    end
    if Fk:getCardById(use.card:getMark(self.name)).suit == Card.Club then
      card = Fk:cloneCard("supply_shortage")
    end
    card:addSubcards({use.card:getMark(self.name)})
    card.skillName = self.name
    player:addVirtualEquip(card)
    player.room:moveCardTo(card, Player.Judge, player, fk.ReasonJustMove, self.name, nil, true, player.id)
  end,
  enabled_at_play  = function (self, player)
    return not table.contains(player.sealedSlots, Player.JudgeSlot) and
      not (player:hasDelayedTrick("indulgence") and player:hasDelayedTrick("supply_shortage"))
  end,
  enabled_at_response = function(self, player, response)
    return not response and not table.contains(player.sealedSlots, Player.JudgeSlot) and
      not (player:hasDelayedTrick("indulgence") and player:hasDelayedTrick("supply_shortage"))
  end,
}
local sk__xiyu = fk.CreateTriggerSkill{
  name = "sk__xiyu",
  anim_type = "support",
  events = {fk.TurnStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and
      table.find(player.room.alive_players, function (p)
        return not p:isAllNude()
      end)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function (p)
      return not p:isAllNude()
    end)
    local to = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1,
      "#sk__xiyu-choose", self.name, true)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    local card = room:askForCardChosen(player, to, "hej", self.name, "#sk__xiyu-discard::"..to.id)
    room:throwCard(card, self.name, to, player)
    if not to.dead then
      to:gainAnExtraPhase(Player.Play)
    end
  end,
}
local sk__wanrou = fk.CreateTriggerSkill{
  name = "sk__wanrou",
  anim_type = "support",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      for _, move in ipairs(data) do
        if move.from == player.id then
          if move.toArea == Card.DiscardPile then
            for _, info in ipairs(move.moveInfo) do
              if (info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip) and
                Fk:getCardById(info.cardId).suit == Card.Diamond then
                return true
              end
              if info.fromArea == Card.PlayerJudge then
                return true
              end
            end
          elseif move.toArea == Card.Processing then
            for _, info in ipairs(move.moveInfo) do
              if info.fromArea == Card.PlayerJudge then
                return true
              end
            end
          end
        end
      end
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local to = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, 1,
      "#sk__wanrou-choose", self.name, true)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:getPlayerById(self.cost_data):drawCards(1, self.name)
  end,
}
daqiao:addSkill(sk__fangxin)
daqiao:addSkill(sk__xiyu)
daqiao:addSkill(sk__wanrou)
Fk:loadTranslationTable{
  ["sk_sr__daqiao"] = "大乔",
  ["#sk_sr__daqiao"] = "韶光易逝",

  ["sk__fangxin"] = "芳馨",
  [":sk__fangxin"] = "当你需使用【桃】时，你可以将一张<font color='red'>♦</font>牌当【乐不思蜀】或将一张♣牌当【兵粮寸断】置入你的判定区，"..
  "视为你使用之。",
  ["sk__xiyu"] = "细语",
  [":sk__xiyu"] = "回合开始时，你可以弃置一名角色区域内的一张牌，令其执行一个额外出牌阶段。",
  ["sk__wanrou"] = "婉柔",
  [":sk__wanrou"] = "当你的<font color='red'>♦</font>牌进入弃牌堆后，或当你判定区内的牌进入处理区或弃牌堆后，你可以令一名角色摸一张牌。",
  ["#sk__fangxin"] = "芳馨：你可以将<font color='red'>♦</font>牌当【乐不思蜀】或♣牌当【兵粮寸断】置入你的判定区，视为使用【桃】",
  ["#sk__xiyu-choose"] = "细语：弃置一名角色区域内一张牌，令其执行一个额外出牌阶段",
  ["#sk__xiyu-discard"] = "细语：弃置 %dest 区域内一张牌",
  ["#sk__wanrou-choose"] = "婉柔：你可以令一名角色摸一张牌",

  ["$sk__fangxin1"] = "您累了。",
  ["$sk__fangxin2"] = "不知您为何事烦恼？",
  ["$sk__xiyu"] = "让您费心了。",
  ["$sk__wanrou"] = "我准备好了。",
  ["~sk_sr__daqiao"] = "青灯长伴，了此余生。",
}

local luxun = General(extension, "sk_sr__luxun", "wu", 3)
local sk__dailao = fk.CreateActiveSkill{
  name = "sk__dailao",
  anim_type = "control",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__dailao",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0 and to_select ~= player.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local choices = {"sk__dailao_draw"}
    if not player:isNude() or not target:isNude() then
      table.insert(choices, "sk__dailao_discard")
    end
    local choice = room:askForChoice(player, choices, self.name, "#sk__dailao-choice::"..target.id)
    if choice == "sk__dailao_draw" then
      player:drawCards(1, self.name)
      if not target.dead then
        target:drawCards(1, self.name)
      end
    else
      room:askForDiscard(player, 1, 1, true, self.name, false)
      if not target.dead then
        room:askForDiscard(target, 1, 1, true, self.name, false)
      end
    end
    if not player.dead then
      player:turnOver()
    end
    if not target.dead then
      target:turnOver()
    end
  end,
}
local sk__youdi = fk.CreateViewAsSkill{
  name = "sk__youdi",
  pattern = "jink",
  anim_type = "defensive",
  prompt = "#sk__youdi",
  card_filter = Util.FalseFunc,
  view_as = function(self, cards,player)
    local card = Fk:cloneCard("jink")
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, use)
    player:turnOver()
  end,
  enabled_at_play = Util.FalseFunc,
  enabled_at_response = function (self, player, response)
    return not player.faceup
  end,
}
local sk__youdi_trigger = fk.CreateTriggerSkill{
  name = "#sk__youdi_trigger",
  mute = true,
  main_skill = sk__youdi,
  events = {fk.CardEffectCancelledOut},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(sk__youdi) and target ~= player and data.to == player.id and data.card.trueName == "slash" and
      not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local cards = player.room:askForDiscard(player, 1, player:getHandcardNum(), true, "sk__youdi", true, ".",
      "#sk__youdi-invoke::"..target.id)
    if #cards > 0 then
      self.cost_data = cards
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("sk__youdi")
    room:notifySkillInvoked(player, "sk__youdi", "control")
    room:doIndicate(player.id, {target.id})
    room:throwCard(self.cost_data, "sk__youdi", player, player)
    if player.dead or target.dead or target:isNude() then return end
    local n = #self.cost_data
    local cards = room:askForCardsChosen(player, target, 1, n, "he", "sk__youdi", "#sk__youdi-discard::"..target.id..":"..n)
    room:throwCard(cards, "sk__youdi", target, player)
  end,
}
local sk__ruya = fk.CreateTriggerSkill{
  name = "sk__ruya",
  anim_type = "drawcard",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and player:isKongcheng() then
      for _, move in ipairs(data) do
        if move.from == player.id then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand then
              return true
            end
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(player.maxHp - player:getHandcardNum(), self.name)
    if not player.dead then
      player:turnOver()
    end
  end,
}
sk__youdi:addRelatedSkill(sk__youdi_trigger)
luxun:addSkill(sk__dailao)
luxun:addSkill(sk__youdi)
luxun:addSkill(sk__ruya)
Fk:loadTranslationTable{
  ["sk_sr__luxun"] = "陆逊",
  ["#sk_sr__luxun"] = "焚天落奕",

  ["sk__dailao"] = "待劳",
  [":sk__dailao"] = "出牌阶段限一次，你可以选择一名其他角色，你选择与其各摸一张牌或弃置一张牌，然后翻面。",
  ["sk__youdi"] = "诱敌",
  [":sk__youdi"] = "当你需使用或打出【闪】时，若你的武将牌背面朝上，你可以翻面，视为使用或打出之。当你使用【闪】抵消其他角色使用的【杀】时，"..
  "你可以弃置任意张牌，然后弃置其等量的牌。",
  ["sk__ruya"] = "儒雅",
  [":sk__ruya"] = "当你失去手牌后，若你没有手牌，你可以将手牌摸至体力上限并翻面。",
  ["#sk__dailao"] = "待劳：选择一名角色，双方各摸一张牌或弃一张牌，然后翻面",
  ["sk__dailao_draw"] = "各摸一张牌",
  ["sk__dailao_discard"] = "各弃置一张牌",
  ["#sk__dailao-choice"] = "待劳：选择与 %dest 依次执行的一项",
  ["#sk__youdi"] = "诱敌：你可以翻面，视为使用或打出【闪】",
  ["#sk__youdi_trigger"] = "诱敌",
  ["#sk__youdi-invoke"] = "诱敌：你可以弃置任意张手牌，弃置 %dest 等量的牌",
  ["#sk__youdi-discard"] = "诱敌：弃置 %dest 至多%arg张牌",

  ["$sk__dailao1"] = "散兵游勇，不攻自破！",
  ["$sk__dailao2"] = "广施方略，以观其变。",
  ["$sk__youdi"] = "兵者，以诈立，以利动。",
  ["$sk__ruya"] = "劳谦虚己，则附之者众。",
  ["~sk_sr__luxun"] = "吾，尚不堪大任……",
}

local sunshangxiang = General(extension, "sk_sr__sunshangxiang", "wu", 3, 3, General.Female)
local sk__yinmeng = fk.CreateActiveSkill{
  name = "sk__yinmeng",
  anim_type = "support",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__yinmeng",
  can_use = function(self, player)
    return not player:isKongcheng() and player:usedSkillTimes(self.name, Player.HistoryPhase) < math.max(player:getLostHp(), 1)
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    local target = Fk:currentRoom():getPlayerById(to_select)
    return #selected == 0 and to_select ~= player.id and not target:isKongcheng() and
      (target.gender == General.Male or target.gender == General.Bigender)
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local card1 = room:askForCardChosen(player, target, "h", self.name, "#sk__yinmeng-choose::"..target.id)
    local type1 = Fk:getCardById(card1).type
    target:showCards(card1)
    if player.dead or player:isKongcheng() then return end
    local card2 = room:askForCard(player, 1, 1, false, self.name, false, ".", "#sk__yinmeng-show")
    local type2 = Fk:getCardById(card2[1]).type
    player:showCards(card2)
    if type1 == type2 then
      if not player.dead then
        player:drawCards(1, self.name)
      end
      if not target.dead then
        target:drawCards(1, self.name)
      end
    else
      if table.contains(target:getCardIds("h"), card1) then
        room:throwCard(card1, self.name, target, player)
      end
    end
  end,
}
local sk__xiwu = fk.CreateTriggerSkill{
  name = "sk__xiwu",
  anim_type = "offensive",
  events = {fk.CardEffectCancelledOut},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, self.name)
    local to = room:getPlayerById(data.to)
    if player.dead or to.dead or to:isNude() then return end
    local card = room:askForCardChosen(player, to, "he", self.name, "#sk__xiwu-discard::"..data.to)
    room:throwCard(card, self.name, to, to)
  end,
}
local sk__juelie = fk.CreateActiveSkill{
  name = "sk__juelie",
  anim_type = "control",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__juelie",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0 and to_select ~= player.id and
      player:getHandcardNum() ~= Fk:currentRoom():getPlayerById(to_select):getHandcardNum()
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local n = player:getHandcardNum() - target:getHandcardNum()
    if n < 0 then
      n = -n
      if #room:askForDiscard(target, n, n, false, self.name, true, ".", "#sk__juelie-discard:"..player.id.."::"..n) < n then
        room:useVirtualCard("slash", nil, player, target, self.name, true)
      end
    else
      local choice = room:askForChoice(target, {"sk__juelie_draw:::"..n, "sk__juelie_slash:"..player.id}, self.name)
      if choice[12] == "d" then
        target:drawCards(n, self.name)
      else
        room:useVirtualCard("slash", nil, player, target, self.name, true)
      end
    end
  end,
}
sunshangxiang:addSkill(sk__yinmeng)
sunshangxiang:addSkill(sk__xiwu)
sunshangxiang:addSkill(sk__juelie)
Fk:loadTranslationTable{
  ["sk_sr__sunshangxiang"] = "孙尚香",
  ["#sk_sr__sunshangxiang"] = "不让须眉",

  ["sk__yinmeng"] = "姻盟",
  [":sk__yinmeng"] = "出牌阶段限X次（X为你已损失体力值且至少为1），若你有手牌，你可以展示一名其他男性角色的一张手牌，然后你展示一张手牌，"..
  "若两张牌类别：相同，你与其各摸一张牌；不同，你弃置其展示的牌。",
  ["sk__xiwu"] = "习武",
  [":sk__xiwu"] = "当你使用【杀】被目标角色使用【闪】抵消时，你可以摸一张牌，然后弃置其一张手牌。",
  ["sk__juelie"] = "决裂",
  [":sk__juelie"] = "出牌阶段限一次，你可以令一名手牌数与你不同的其他角色选择一项：1.将手牌摸或弃至与你相同；2.视为你对其使用【杀】。",
  ["#sk__yinmeng"] = "姻盟：展示一名角色一张手牌和你的一张手牌，若类别相同双方摸牌，若不同弃置对方的牌",
  ["#sk__yinmeng-choose"] = "姻盟：选择 %dest 一张手牌展示",
  ["#sk__yinmeng-show"] = "姻盟：展示一张手牌",
  ["#sk__xiwu-discard"] = "习武：弃置 %dest 一张牌",
  ["#sk__juelie"] = "决裂：令一名角色选择将手牌调整至与你相同，或视为你对其使用【杀】",
  ["#sk__juelie-discard"] = "决裂：弃置%arg张手牌，否则视为 %src 对你使用【杀】",
  ["sk__juelie_draw"] = "摸%arg张牌",
  ["sk__juelie_slash"] = "视为 %src 对你使用【杀】",

  ["$sk__yinmeng"] = "君心知我心，君意共我意。",
  ["$sk__xiwu"] = "绝不允许你这般胡来！",
  ["$sk__juelie"] = "休要小看我！",
  ["~sk_sr__sunshangxiang"] = "不……我不能输……",
}

local huatuo = General(extension, "sk_sr__huatuo", "qun", 3)
local sk__xingyi = fk.CreateActiveSkill{
  name = "sk__xingyi",
  anim_type = "support",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__xingyi",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0 and to_select ~= player.id and not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local card = room:askForCardChosen(player, target, "h", self.name, "#sk__xingyi-choose::"..target.id)
    room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, true, player.id)
    if not target.dead and target:isWounded() then
      room:recover{
        who = target,
        num = 1,
        recoverBy = player,
        skillName = self.name,
      }
    end
  end,
}
local sk__guagu = fk.CreateTriggerSkill{
  name = "sk__guagu",
  anim_type = "support",
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and not target:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, data, "#sk__guagu-invoke::"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    local n = #table.filter(target:getCardIds("h"), function (id)
      return not target:prohibitDiscard(id)
    end)
    target:throwAllCards("h")
    if target.dead then return end
    if target.hp < 1 then
      room:recover{
        who = target,
        num = 1 - target.hp,
        recoverBy = player,
        skillName = self.name,
      }
    end
    if not target.dead and n > 1 then
      target:drawCards(1, self.name)
    end
  end,
}
local sk__wuqin = fk.CreateTriggerSkill{
  name = "sk__wuqin",
  anim_type = "drawcard",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForDiscard(player, 1, 1, false, self.name, true, ".|.|.|.|.|basic", "#sk__wuqin-invoke", true)
    if #card > 0 then
      self.cost_data = card
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard(self.cost_data, self.name, player, player)
    if player.dead then return end
    local choice = room:askForChoice(player, {"draw2", "sk__wuqin_2"}, self.name)
    if choice == "draw2" then
      player:drawCards(2, self.name)
    else
      player:gainAnExtraPhase(Player.Play)
    end
  end,
}
huatuo:addSkill(sk__xingyi)
huatuo:addSkill(sk__guagu)
huatuo:addSkill(sk__wuqin)
Fk:loadTranslationTable{
  ["sk_sr__huatuo"] = "华佗",
  ["#sk_sr__huatuo"] = "圣手仁心",

  ["sk__xingyi"] = "行医",
  [":sk__xingyi"] = "出牌阶段限一次，你可以获得一名其他角色的一张手牌，然后其回复1点体力。",
  ["sk__guagu"] = "刮骨",
  [":sk__guagu"] = "当一名角色进入濒死状态时，你可以令其弃置所有手牌，回复体力至1点，若其以此法弃置的牌数不小于2，其摸一张牌。",
  ["sk__wuqin"] = "五禽",
  [":sk__wuqin"] = "结束阶段，你可以弃置一张基本牌，然后摸两张牌或进行一个额外出牌阶段。",
  ["#sk__xingyi"] = "行医：获得一名角色的一张手牌，然后其回复1点体力",
  ["#sk__xingyi-choose"] = "行医：获得一名 %dest 的一张手牌",
  ["#sk__guagu-invoke"] = "刮骨：是否令 %dest 弃置所有手牌，回复体力至1点？",
  ["#sk__wuqin-invoke"] = "五禽：你可以弃一张基本牌，摸两张牌或进行一个额外出牌阶段",
  ["sk__wuqin_2"] = "获得额外出牌阶段",

  ["$sk__xingyi"] = "病根虽除，仍需调养百日。",
  ["$sk__guagu"] = "君侯身体要紧，岂能拖延？",
  ["$sk__wuqin"] = "流水不腐，户枢不蠹。",
  ["~sk_sr__huatuo"] = "人可医，国难医啊……",
}

local lvbu = General(extension, "sk_sr__lvbu", "qun", 4)
local sk__jiwu = fk.CreateActiveSkill{
  name = "sk__jiwu",
  anim_type = "offensive",
  card_num = function ()
    if Self:isKongcheng() then
      return 0
    else
      return Self:getHandcardNum() - 1
    end
  end,
  target_num = 0,
  prompt = "#sk__jiwu",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 and player:getHandcardNum() ~= 1
  end,
  card_filter = function (self, to_select, selected,player)
    if player:isKongcheng() then
      return false
    else
      return #selected < (player:getHandcardNum() - 1) and not player:prohibitDiscard(to_select) and
        Fk:currentRoom():getCardArea(to_select) == Card.PlayerHand
    end
  end,
  feasible = function (self, selected, selected_cards,player)
    if player:isKongcheng() then
      return #selected_cards == 0
    else
      return #selected_cards == (player:getHandcardNum() - 1)
    end
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    if #effect.cards > 0 then
      room:throwCard(effect.cards, self.name, player, player)
    else
      player:drawCards(1, self.name)
    end
  end,
}
local sk__jiwu_delay = fk.CreateTriggerSkill{
  name = "#sk__jiwu_delay",
  mute = true,
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:usedSkillTimes("sk__jiwu", Player.HistoryTurn) > 0 and data.card.trueName == "slash"
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:broadcastSkillInvoke("sk__jiwu")
    player.room:notifySkillInvoked(player, "sk__jiwu", "offensive")
    data.additionalDamage = (data.additionalDamage or 0) + 1
  end,
}
local sk__jiwu_targetmod = fk.CreateTargetModSkill{
  name = "#sk__jiwu_targetmod",
  main_skill = sk__jiwu,
  bypass_distances =  function(self, player, skill)
    return skill.trueName == "slash_skill" and player:usedSkillTimes("sk__jiwu", Player.HistoryTurn) > 0
  end,
  extra_target_func = function(self, player, skill)
    if skill.trueName == "slash_skill" and player:hasSkill(sk__jiwu) and #player:getCardIds("e") == 0 then
      return 2
    end
  end,
}
local sk__sheji = fk.CreateViewAsSkill{
  name = "sk__sheji",
  anim_type = "offensive",
  pattern = "slash",
  prompt = "#sk__sheji",
  card_filter = function(self, to_select, selected,player)
    return #selected == 0 and Fk:getCardById(to_select).type == Card.TypeEquip
  end,
  view_as = function(self, cards,player)
    if #cards ~= 1 then return nil end
    local card = Fk:cloneCard("slash")
    card:addSubcard(cards[1])
    card.skillName = self.name
    return card
  end,
}
local sk__sheji_trigger = fk.CreateTriggerSkill{
  name = "#sk__sheji_trigger",
  mute = true,
  events = {fk.Damage},
  main_skill = sk__sheji,
  can_trigger = function(self, event, target, player, data)
    return target and target ~= player and player:hasSkill(sk__sheji) and #target:getEquipments(Card.SubtypeWeapon) > 0 and
      not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForDiscard(player, 1, 1, true, "sk__sheji", true, ".", "#sk__sheji-invoke::"..target.id, true)
    if #card > 0 then
      self.cost_data = card
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("sk__sheji")
    room:notifySkillInvoked(player, "sk__sheji", "control")
    room:throwCard(self.cost_data, self.name, player, player)
    local cards = target:getEquipments(Card.SubtypeWeapon)
    if player.dead or #cards == 0 then return end
    room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonPrey, "sk__sheji", nil, true, player.id)
  end,

  refresh_events = {fk.TargetSpecified},
  can_refresh = function(self, event, target, player, data)
    return target == player and table.contains(data.card.skillNames, "sk__sheji")
  end,
  on_refresh = function(self, event, target, player, data)
    data.fixedResponseTimes = data.fixedResponseTimes or {}
    data.fixedResponseTimes["jink"] = 2
  end,
}
local sk__sheji_targetmod = fk.CreateTargetModSkill{
  name = "#sk__sheji_targetmod",
  bypass_distances =  function(self, player, skill, card)
    return skill.trueName == "slash_skill" and table.contains(card.skillNames, "sk__sheji")
  end,
}
sk__jiwu:addRelatedSkill(sk__jiwu_delay)
sk__jiwu:addRelatedSkill(sk__jiwu_targetmod)
sk__sheji:addRelatedSkill(sk__sheji_trigger)
sk__sheji:addRelatedSkill(sk__sheji_targetmod)
lvbu:addSkill(sk__jiwu)
lvbu:addSkill(sk__sheji)
Fk:loadTranslationTable{
  ["sk_sr__lvbu"] = "吕布",
  ["#sk_sr__lvbu"] = "虓虎之勇",

  ["sk__jiwu"] = "极武",
  [":sk__jiwu"] = "出牌阶段限一次，你可以将手牌摸或弃至一张，若如此做，直到回合结束，你使用【杀】无距离限制且伤害+1。若你的装备区内没有牌，"..
  "你使用【杀】目标上限+2。",
  ["sk__sheji"] = "射戟",
  [":sk__sheji"] = "你可以将装备牌当无距离限制的【杀】使用或打出，你以此法使用的【杀】目标角色需连续使用两张【闪】抵消。当其他角色造成伤害后，"..
  "若其装备区内有武器牌，你可以弃置一张牌，获得之。",
  ["#sk__jiwu"] = "极武：将手牌摸或弃至一张，直到回合结束获得效果",
  ["#sk__jiwu_delay"] = "极武",
  ["#sk__sheji"] = "射戟：你可以将装备牌当无距离限制的【杀】使用或打出",
  ["sk__sheji_trigger"] = "射戟",
  ["#sk__sheji-invoke"] = "射戟：你可以弃一张牌，获得 %dest 装备区的武器牌",

  ["$sk__jiwu1"] = "谁敢挡我！",
  ["$sk__jiwu2"] = "真是无趣，你们一起上吧！",
  ["$sk__sheji"] = "够胆的话，就来试试！",
  ["~sk_sr__lvbu"] = "有意思，哼哼哈哈哈哈！",
}

local diaochan = General(extension, "sk_sr__diaochan", "qun", 3, 3, General.Female)
local sk__manwu = fk.CreateActiveSkill{
  name = "sk__manwu",
  anim_type = "control",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__manwu",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    local target = Fk:currentRoom():getPlayerById(to_select)
    return #selected == 0 and to_select ~= player.id and not target:isKongcheng() and
      (target.gender == General.Male or target.gender == General.Bigender)
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local card = room:askForCardChosen(player, target, "h", self.name, "#sk__manwu-choose::"..target.id)
    local suit = Fk:getCardById(card).suit
    target:showCards(card)
    if not table.contains(target:getCardIds("h"), card) then return end
    if suit == Card.Diamond then
      if not target.dead and not table.contains(target.sealedSlots, Player.JudgeSlot) and
        not target:hasDelayedTrick("indulgence") then
      local c = Fk:cloneCard("indulgence")
      c:addSubcards({card})
      c.skillName = self.name
      target:addVirtualEquip(c)
      room:moveCardTo(c, Player.Judge, target, fk.ReasonJustMove, self.name, nil, true, player.id)
      end
    elseif not player.dead then
      room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, true, player.id)
    end
  end,
}
local sk__baiyue = fk.CreateTriggerSkill{
  name = "sk__baiyue",
  anim_type = "drawcard",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) and player.phase == Player.Finish then
      local turn_event = player.room.logic:getCurrentEvent():findParent(GameEvent.Turn, true)
      if turn_event == nil then return end
      return #player.room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function (e)
        for _, move in ipairs(e.data) do
          if move.from and move.from ~= player.id then
            for _, info in ipairs(move.moveInfo) do
              if player.room:getCardArea(info.cardId) == Card.DiscardPile then
                return true
              end
            end
          end
        end
      end, Player.HistoryTurn) > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = {}
    room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function (e)
      for _, move in ipairs(e.data) do
        if move.from and move.from ~= player.id then
          for _, info in ipairs(move.moveInfo) do
            if room:getCardArea(info.cardId) == Card.DiscardPile then
              table.insertIfNeed(cards, info.cardId)
            end
          end
        end
      end
    end, Player.HistoryTurn)
    cards = U.askforChooseCardsAndChoice(player, cards, {"OK"}, self.name, "#sk__baiyue-card", {}, 1, 1)
    room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
  end,
}
diaochan:addSkill("lijian")
diaochan:addSkill(sk__manwu)
diaochan:addSkill(sk__baiyue)
Fk:loadTranslationTable{
  ["sk_sr__diaochan"] = "貂蝉",
  ["#sk_sr__diaochan"] = "歌舞升平",

  ["sk__manwu"] = "曼舞",
  [":sk__manwu"] = "出牌阶段限一次，你可以展示一名男性角色的一张手牌，若此牌为<font color='red'>♦</font>，将之当【乐不思蜀】置入其判定区，"..
  "否则你获得之。",
  ["sk__baiyue"] = "拜月",
  [":sk__baiyue"] = "结束阶段，你可以获得弃牌堆中一张其他角色于此回合内失去过的牌。",
  ["#sk__manwu"] = "曼舞：展示一名角色一张手牌，若为<font color='red'>♦</font>当【乐不思蜀】置入其判定区，否则你获得之",
  ["#sk__manwu-choose"] = "曼舞：选择 %dest 一张手牌展示",
  ["#sk__baiyue-card"] = "拜月：获得其中一张牌",

  ["$sk__manwu"] = "让妾身，为您献上一舞~",
  ["$sk__baiyue"] = "羡慕吧。",
  ["~sk_sr__diaochan"] = "红颜多薄命，几人能白头……",
}

return extension
